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
        private void AddBreakJump()
        {
            if (breakJumps.Any())
            {
                var breakJump = new JumpInstruction();
                AddInstruction(breakJump);
                var currentScopeJumpList = breakJumps.Peek();

                currentScopeJumpList.Add(breakJump);
            }
        }