public override void ExitAssign(ssuplParser.AssignContext context) { // assign : ID EQ expr string vname = context.ID().GetText(); if (symtable.Get(vname).type != type(context.expr()))//invalid input check { throw new Exception("Type mismatch"); } if (!symtable.Contains(vname)) { throw new Exception("Undeclared variable: " + vname); } code.Put(context, code.Get(context.expr()), "pop rax", $"mov [${symtable.Get(vname).location}],rax" //, //"push rax" ); }
public override void ExitAssign(ssuplParser.AssignContext context) { // assign : ID EQ expr string vname = context.ID().GetText(); if (!symtable.Contains(vname)) { throw new Exception("Undeclared variable: " + vname); } code.Put(context, code.Get(context.expr()), "pop rax", $"mov [${symtable.Get(vname).location}],rax" ); }