Пример #1
0
        public override void ExitCondNoElse(ssuplParser.CondNoElseContext context)
        {
            //cond : IF LP expr RP braceblock
            //new
            if (type(context.expr()) != VarType.INT)
            {
                throw new Exception("Condition must be integer type");
            }
            //end new

            string endif = label();

            code.Put(context,
                     $"; begin condNoElse at line {context.Start.Line}",
                     code.Get(context.expr()),
                     "pop rax",
                     "cmp rax,0",
                     $"je {endif}",
                     $";begin condNoElse braceblock",
                     code.Get(context.braceblock()),
                     $"{endif}:",
                     $"; end condNoElse at line {context.Stop.Line}"

                     );
        }
Пример #2
0
        public override void ExitCondNoElse(ssuplParser.CondNoElseContext context)
        {
            string endif = label();

            code.Put(context,
                     code.Get(context.expr()),
                     "cmp rax,0",
                     $"je {endif}",
                     code.Get(context.braceblock()),
                     $"{endif}:"
                     );
        }
 /// <summary>
 /// Exit a parse tree produced by the <c>condNoElse</c>
 /// labeled alternative in <see cref="ssuplParser.cond"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitCondNoElse([NotNull] ssuplParser.CondNoElseContext context)
 {
 }