static AST asnstmt(AST name) { Token *t = &tok; AST a=0; AST a1=0,a2=0; int idx,op; switch (t->sym) { case ASNOP: /* change name to VREF */ set_nodetype(name, nVREF); idx = lookup_SYM_all(get_text(name)); set_ival(name,idx); a1 = name; break; case '[': /* change name to LVAL */ set_nodetype(name, nVREF); a2 = exprs(); a1 = make_AST(nLVAL, name, a2, 0, 0) ; break; default: break; } op = t->ival; gettoken(); a2 = expr(); a = make_AST_asn(op,a1,a2); return a; }
JNIEXPORT jint JNICALL Java_edu_berkeley_bid_CUMAT_setival (JNIEnv *env, jobject obj, jobject jA, jint vv, jint length) { float *nativeA = (float*)getPointer(env, jA); return set_ival(nativeA, vv, length); }
static AST argdecl() { Token *t = &tok; AST a=0; AST a1=0,a2=0; int idx; a2 = typedecl(); a1 = var(); a = make_AST_argdecl(a1, a2); idx = insert_SYM(get_text(a1), a2, vARG, a1); set_ival(a1,idx); return a; }
static AST vardecl() { /* TODO: allow vars */ Token *t = &tok; AST a=0; AST a1=0,a2=0,a3=0,a4=0; AST ft; int idx; a2 = typedecl(); a1 = var(); if (t->sym == '(') { /* oops, it was func */ gettoken(); set_nodetype(a1, nNAME); /* change to NAME */ insert_SYM(get_text(a1), ft=func_type(gen(fLOCAL),a2), fLOCAL,0 /* dummy */ ); a3 = argdecls(); set_argtypeofnode(ft,a3); if (t->sym == ')') gettoken(); else parse_error("expected )"); a4 = block(); a = make_AST_funcdecl(a1, a2, a3, a4); } else if (t->sym == ';') { /* vardecl */ a = make_AST_vardecl(a1, a2, 0, 0); idx = insert_SYM(get_text(a1), a2, vLOCAL, a1); set_ival(a1,idx); /* } else if (t->sym == ',') { // multiple vars * contents must be made * */ } else { parse_error("expected ; or ("); } return a; }
void initVal(int i) const { set_ival(i); }