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" ); }
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" ); }
/// <summary> /// Exit a parse tree produced by <see cref="ssuplParser.assign"/>. /// <para>The default implementation does nothing.</para> /// </summary> /// <param name="context">The parse tree.</param> public virtual void ExitAssign([NotNull] ssuplParser.AssignContext context) { }