static void AssignmentOrCall() { int expType; DesType des; if (IsCall(out des)) { Expect(identifier_Sym); CodeGen.FrameHeader(); Expect(lparen_Sym); Arguments(des); Expect(rparen_Sym); CodeGen.Call(des.entry.entryPoint); } else if (la.kind == identifier_Sym) { Designator(out des); if (des.entry.kind != Kinds.Var) { SemError("cannot assign to " + Kinds.kindNames[des.entry.kind]); } AssignOp(); Expression(out expType); if (!Assignable(des.type, expType)) { SemError("incompatible types in assignment"); } CodeGen.Assign(des.type); } else { SynErr(48); } ExpectWeak(semicolon_Sym, 6); }
static void OneVar(StackFrame frame, int type) { int expType; Entry var = new Entry(); Ident(out var.name); var.kind = Kinds.Var; var.type = type; var.offset = frame.size; frame.size++; if (la.kind == equal_Sym) { AssignOp(); CodeGen.LoadAddress(var); Expression(out expType); if (!Assignable(var.type, expType)) { SemError("incompatible types in assignment"); } CodeGen.Assign(var.type); } Table.Insert(var); }