Exemple #1
0
        public override void GenerateBytecode(ClassesContainer container, ByteBlock context)
        {
            int jumpIndex = context.NextOpIndex;

            IfCondition.GenerateBytecode(container, context);

            JumpIfFalseCode jumpIfFalse = new JumpIfFalseCode(-1);

            context.Instructions.Add(jumpIfFalse);

            foreach (var statement in IfStatements)
            {
                statement.GenerateBytecode(container, context);
            }

            JumpCode jumpElseIfTrue = new JumpCode(-1);

            context.Instructions.Add(jumpElseIfTrue);

            jumpIfFalse.targetIndex = context.NextOpIndex;

            if (ElseStatements != null)
            {
                foreach (var statement in ElseStatements)
                {
                    statement.GenerateBytecode(container, context);
                }
            }

            jumpElseIfTrue.targetIndex = context.NextOpIndex;
        }
        public override void GenerateBytecode(ClassesContainer container, ByteBlock context)
        {
            int jumpIndex = context.NextOpIndex;

            Condition.GenerateBytecode(container, context);

            JumpIfFalseCode jumpIfFalse = new JumpIfFalseCode(-1);

            context.Instructions.Add(jumpIfFalse);

            foreach (var statement in Statements)
            {
                statement.GenerateBytecode(container, context);
            }

            context.Instructions.Add(new JumpCode(jumpIndex));

            jumpIfFalse.targetIndex = context.NextOpIndex;
        }