Ejemplo n.º 1
0
        private JSProgram CreateProgramWithWhileStatement(int whileTimes)
        {
            JSProgram program = new JSProgram();

            program.Render = true;
            program.AddInputBlock("a", 1);
            program.AddHeaterDeclarationBlock("z");

            string times      = program.AddConstantBlock(whileTimes);
            string zero       = program.AddConstantBlock(whileTimes);
            string logicCheck = program.AddBoolOPBlock(BoolOPTypes.EQ, times, zero);

            string scopeName = program.GetUniqueName();

            program.AddScope(scopeName);
            program.SetScope(scopeName);
            string guardedBlock = AddFluidBlock(program, "a", "k");

            program.SetScope(JSProgram.DEFAULT_SCOPE_NAME);

            program.AddRepeatSegment(times, guardedBlock);
            AddFluidBlock(program, "k", "k");

            program.Finish();
            return(program);
        }
Ejemplo n.º 2
0
        private JSProgram CreateProgramWithoutRepeatStatement(int repeatTimes)
        {
            JSProgram program = new JSProgram();

            program.AddInputBlock("a", 1);
            program.AddHeaterDeclarationBlock("z");

            AddFluidBlock(program, "a", "k");
            for (int i = 0; i < repeatTimes; i++)
            {
                AddFluidBlock(program, "k", "k");
            }

            program.Finish();
            return(program);
        }
Ejemplo n.º 3
0
        private JSProgram CreateProgramWithIfStatement(bool[][] enableIfs)
        {
            JSProgram program = new JSProgram();

            program.Render = true;
            program.AddInputBlock("a", 1);
            program.AddHeaterDeclarationBlock("z");

            AddFluidBlock(program, "a", "k");
            foreach (bool[] enableIf in enableIfs)
            {
                nestIfs(program, JSProgram.DEFAULT_SCOPE_NAME, new Queue <bool>(enableIf), "k", "k");
            }

            program.Finish();
            return(program);
        }
Ejemplo n.º 4
0
        private JSProgram CreateProgramWithRepeatStatement(int[][] repeatTimes)
        {
            JSProgram program = new JSProgram();

            program.Render = true;
            program.AddInputBlock("a", 1);
            program.AddHeaterDeclarationBlock("z");

            AddFluidBlock(program, "a", "k");
            foreach (int[] repeats in repeatTimes)
            {
                nestRepeats(program, JSProgram.DEFAULT_SCOPE_NAME, new Queue <int>(repeats), "k", "k");
            }

            program.Finish();
            return(program);
        }
Ejemplo n.º 5
0
        private JSProgram CreateProgramWithoutIfStatement(bool[] enableIfs)
        {
            JSProgram program = new JSProgram();

            program.Render = true;
            program.AddInputBlock("a", 1);
            program.AddHeaterDeclarationBlock("z");

            AddFluidBlock(program, "a", "k");
            foreach (bool enableIf in enableIfs)
            {
                if (enableIf)
                {
                    AddFluidBlock(program, "k", "k");
                }
                AddFluidBlock(program, "k", "k");
            }

            program.Finish();
            return(program);
        }