Go to the documentation of this file. 1 package com.cliffc.aa.node;
7 import java.util.ArrayList;
8 import java.util.Collections;
9 import java.util.HashSet;
105 for(
PrimNode prim : uniops ) prim._op_prec = (byte)max_prec;
109 HashSet<String> hash =
new HashSet<>();
112 hash.add(prim._name);
113 ArrayList<String> list =
new ArrayList<>(hash);
114 Collections.sort(list);
115 Collections.reverse(list);
120 for(
int p=0; p<max_prec; p++ ) {
122 for(
int i=0; i<toks.length; i++ )
141 boolean is_con =
true, has_high =
false;
142 for(
int i=1; i<
_defs._len; i++ ) {
145 Type t = tformal.
dual().meet(ts[i] = tactual);
152 return is_con ?
apply(ts) : (has_high ? rez.
dual() : rez);
155 for(
int i=1; i<
_defs._len; i++ ) {
158 if( !tactual.
isa(tformal) )
167 @Override
public boolean equals(Object o) {
168 if(
this==o )
return true;
169 if( !super.equals(o) )
return false;
170 if( !(o instanceof
PrimNode) )
return false;
186 for(
int i=ARG_IDX; i<
_sig.
nargs(); i++ )
188 Node that = X.xform(
this);
218 for(
int i=1; i<
_defs._len; i++ )
219 ts[i] =
_defs.at(i)._val;
223 Type actual = args[1];
227 assert formal.
dual().isa(actual) && actual.
isa(formal);
233 if( !actual.
isa(formal) )
256 abstract double op(
double d );
261 @Override
double op(
double d ) {
return -d; }
268 abstract long op(
long d );
273 @Override
long op(
long x ) {
return -x; }
280 abstract double op(
double x,
double y );
285 double op(
double l,
double r ) {
return l+r; }
290 double op(
double l,
double r ) {
return l-r; }
295 @Override
double op(
double l,
double r ) {
return l*r; }
300 @Override
double op(
double l,
double r ) {
return l/r; }
307 abstract boolean op(
double x,
double y );
322 abstract long op(
long x,
long y );
327 @Override
long op(
long l,
long r ) {
return l+r; }
332 @Override
long op(
long l,
long r ) {
return l-r; }
337 @Override
long op(
long l,
long r ) {
return l*r; }
342 @Override
long op(
long l,
long r ) {
return l/r; }
347 @Override
long op(
long l,
long r ) {
return l%r; }
356 if( t1 ==
Type. NIL || t2 ==
Type. NIL )
return Type. NIL;
365 if( t1.
is_con() && t2.is_con() )
372 @Override
long op(
long l,
long r ) {
return l&r; }
390 if( t1.
is_con() && t2.is_con() )
397 @Override
long op(
long l,
long r ) {
return l&r; }
404 abstract boolean op(
long x,
long y );
500 @Override
public boolean equals(Object o) {
return this==o; }
518 if(
_defs._len != 4 )
return null;
561 return _defs._len==4 ? null :
in(idx);
575 if(
_defs._len != 4 )
return null;
618 return _defs._len==4 ? null :
in(idx);
static PrimNode[] PRIMS()
abstract long op(long x, long y)
TypeInt apply(Type[] args)
E push(E e)
Add element in amortized constant time.
static TypeTuple make_args(Type[] ts)
boolean op(long l, long r)
Memory type; the state of all of memory; memory edges order memory ops.
static TypeTuple make_ret(Type trez)
abstract Type apply(Type[] args)
static final TypeMemPtr OOP
Type value(GVNGCM.Mode opt_mode)
TypeInt apply(Type[] args)
Type value(GVNGCM.Mode opt_mode)
TypeInt apply(Type[] args)
double op(double l, double r)
boolean op(double l, double r)
static final TypeMem LIVE_BOT
PrimNode(String name, String[] args, TypeTuple formals, Type ret)
boolean op(long l, long r)
static final TypeFunPtr GENERIC_FUNPTR
PrimNode(String name, TypeTuple formals, Type ret)
an implementation of language AA
static TypeFunSig make(String[] args, TypeTuple formals, TypeTuple ret)
Type value(GVNGCM.Mode opt_mode)
static ErrMsg typerr(Parse loc, Type actual, Type t0mem, Type expected)
Type value(GVNGCM.Mode opt_mode)
abstract double op(double x, double y)
boolean op(long l, long r)
static TypeInt con(long con)
static final TypeMem ALLMEM
static final String[] func_names
boolean op(double l, double r)
boolean op(double l, double r)
static RuntimeException unimpl()
double op(double l, double r)
Type value(GVNGCM.Mode opt_mode)
boolean op(long l, long r)
TypeInt apply(Type[] args)
Type value(GVNGCM.Mode opt_mode)
static final TypeTuple SCALAR1
static final TypeInt INT64
Type value(GVNGCM.Mode opt_mode)
final T set_name(String name)
double op(double l, double r)
static Type con(double con)
Type value(GVNGCM.Mode opt_mode)
static final TypeTuple ANDTHEN
Type value(GVNGCM.Mode opt_mode)
static final TypeTuple ORELSE
static final TypeTuple RET
TypeInt maxsize(TypeInt ti)
static final TypeTuple FLT64
Type value(GVNGCM.Mode opt_mode)
static String[][] PREC_TOKS
TypeInt apply(Type[] args)
static PrimNode convertTypeName(Type from, Type to, Parse badargs)
boolean op(double l, double r)
static final TypeMem ALIVE
abstract boolean op(long x, long y)
double op(double l, double r)
boolean op(long l, long r)
static String[] PRIM_TOKS
an implementation of language AA
boolean op(double l, double r)
static final TypeTuple STRPTR
static final TypeTuple INT64_INT64
static final byte OP_PRIM
Node set_def(int idx, Node n)
Prim2RelOpF64(String name)
static final TypeTuple OOP_OOP
TypeInt apply(Type[] args)
ConvertTypeName(Type from, Type to, Parse badargs)
Type value(GVNGCM.Mode opt_mode)
abstract boolean op(double x, double y)
Prim2RelOpI64(String name)
static final TypeInt ZERO
static final TypeTuple FLT64_FLT64
TypeInt minsize(TypeInt ti)
abstract double op(double d)
Type value(GVNGCM.Mode opt_mode)
boolean op(long l, long r)
FunPtrNode as_fun(GVNGCM gvn)
static final TypeInt TRUE
static final TypeTuple INT64
static final ErrMsg BADARGS
boolean op(double l, double r)
static final TypeInt BOOL
TypeInt apply(Type[] args)
an implementation of language AA
static final TypeFlt FLT64
TypeMem live_use(GVNGCM.Mode opt_mode, Node def)
TypeInt apply(Type[] args)
TypeMem live_use(GVNGCM.Mode opt_mode, Node def)
static PrimNode[][] PRECEDENCE
static Type vs_nil(Type tx, Type t, Type f)
static final TypeMemPtr ISUSED0