Exemple #1
0
        private void Generate(injectionParser.IfContext ifContext)
        {
            var ifInstruction = new IfInstruction(ifContext);

            AddInstruction(ifInstruction);
            var endIfJump = new JumpInstruction();

            if (ifContext.codeBlock()?.statement() != null)
            {
                foreach (var statement in ifContext.codeBlock().statement())
                {
                    VisitStatement(statement);
                }
            }

            if (ifContext.@else()?.codeBlock()?.statement() != null)
            {
                AddInstruction(endIfJump);
                ifInstruction.ElseAddress = currentAddress;
                foreach (var statement in ifContext.@else().codeBlock().statement())
                {
                    VisitStatement(statement);
                }
            }

            ifInstruction.EndIfAddress = currentAddress;
            endIfJump.TargetAddress    = currentAddress;
        }
Exemple #2
0
        public override bool VisitIf([NotNull] injectionParser.IfContext context)
        {
            StartContext(MessageSeverity.Warning);

            var result = base.VisitIf(context);

            EndContext();

            return(result);
        }
 public IfInstruction(injectionParser.IfContext ifSyntax)
 {
     IfSyntax  = ifSyntax;
     Statement = (injectionParser.StatementContext)ifSyntax.Parent;
 }