Пример #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}:"
                     );
        }