Esempio n. 1
0
        public static void SolveDoubleJumps(SchemeFunction function)
        {
            bool changed = true;

            var commands = function.Commands;

            while (changed)
            {
                changed = false;

                for (int i = 0; i < commands.Count; ++i)
                {
                    ISchemeCommand cmd = commands[i];
                    if (cmd is CommandJumpBase)
                    {
                        CommandJumpBase jumpCmd = (cmd as CommandJumpBase);
                        int             line    = jumpCmd.Line;
                        if (line < commands.Count && commands[line] is CommandJump)
                        {
                            CommandJump jumpCmd2 = commands[line] as CommandJump;
                            if (jumpCmd.Line != jumpCmd2.Line)
                            {
                                jumpCmd.SetLine(jumpCmd2.Line);
                                changed = true;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
            public override object VisitElse([NotNull] scheme_langParser.ElseContext context)
            {
                CommandJump jump = new CommandJump(-1);

                currentFunc.AddCommand(jump);

                //we must set jump position of latest if (jump-if-false command)
                SetLatestJumpPosition(currentFunc.GetCommandCount());

                jump_cmds.Add(jump);

                VariableManager.EndBlock(); // end if-block
                VariableManager.NewBlock(); // start else-block

                return(base.VisitElse(context));
            }