Ejemplo n.º 1
0
 public CycleWhile(string parseCondition, CommandOrder actions, bool doFirst)
 {
     condition            = new Equal(BinaryOperation.ParseFrom(parseCondition), new ASTvalue(new ValueType(VT.Cboolean), (object)true));
     this.actions         = actions;
     this.doFirst         = doFirst;
     GlobalOperatorNumber = ++MISC.GlobalOperatorNumber;
     FindIterateVars();
 }
Ejemplo n.º 2
0
 public OperatorZone(string parseActions)
 {
     condition = new Equal(new ASTvalue(new ValueType(VT.Cboolean), (object)true), new ASTvalue(new ValueType(VT.Cboolean), (object)true));
     actions   = new List <CommandOrder>();
     MISC.GoDeep("OZONE");
     actions.Add(new CommandOrder(parseActions, ';'));
     MISC.GoBack();
 }
Ejemplo n.º 3
0
 public CycleWhile(string parseCondition, string parseActions, bool doFirst)
 {
     condition = new Equal(BinaryOperation.ParseFrom(parseCondition), new ASTvalue(new ValueType(VT.Cboolean), (object)true));
     MISC.GoDeep("WHILE");
     actions = new CommandOrder(parseActions, ';');
     MISC.GoBack();
     this.doFirst = doFirst;
 }
Ejemplo n.º 4
0
        public OperatorIf(string parseCondition, string parseActions, string parseElseAction)
        {
            condition = new Equal(BinaryOperation.ParseFrom(parseCondition), new ASTvalue(new ValueType(VT.Cboolean), (object)true));
            actions   = new List <CommandOrder>();
            actions.Add(new CommandOrder());
            actions.Add(new CommandOrder());

            MISC.GoDeep("IFTHEN");
            actions[0].MergeWith(new CommandOrder(parseActions, ';'));
            MISC.GoBack();
            if (parseElseAction.Length > 0)
            {
                MISC.GoDeep("IFELSE");
                actions[1].MergeWith(new CommandOrder(parseElseAction, ';'));
                MISC.GoBack();
            }
        }
Ejemplo n.º 5
0
        public static string ToLLVMVariative(int depth, int GlobalOperatorNumber, string type, bool doBeforeWhile, Equal condition, CommandOrder actions, List <ASTvariable> iterateVars)
        {
            LLVM.AddToCode(";" + type + "\n");
            //
            if (!doBeforeWhile)
            {
                LLVM.AddToCode(String.Format("{0}br label %{2}cond{1}\n", MISC.tabsLLVM(depth), GlobalOperatorNumber, type));
                LLVM.AddToCode(String.Format("{0}{2}cond{1}:\n", MISC.tabsLLVM(depth - 1), GlobalOperatorNumber, type));
                // reload all variables in it
                foreach (ASTvariable vari in iterateVars)
                {
                    vari.reloadedTimes++;
                    LLVM.AddToCode(String.Format("{0}{1} = load {2}, {3} {4}\n", MISC.tabsLLVM(depth), vari.ToLLVM(), vari.returnTypes().ToLLVM(), vari.returnTypes().TypeOfPointerToThis().ToLLVM(), MISC.RemoveCall(vari.ToLLVM())));
                }
                string condLine = condition.getTrueEqual().ToLLVM(depth);
                LLVM.AddToCode(String.Format("{0}br i1 {3}, label %{2}action{1}, label %{2}cont{1}\n", MISC.tabsLLVM(depth), GlobalOperatorNumber, type, condLine));

                LLVM.AddToCode(String.Format("{0}{2}action{1}:\n", MISC.tabsLLVM(depth - 1), GlobalOperatorNumber, type));
                LLVM.AddToCode(actions.ToLLVM(depth));
                LLVM.AddToCode(String.Format("{0}br label %{2}cond{1}\n", MISC.tabsLLVM(depth), GlobalOperatorNumber, type));
                LLVM.AddToCode(String.Format("{0}{2}cont{1}:", MISC.tabsLLVM(depth - 1), GlobalOperatorNumber, type));
            }
            else
            {
                LLVM.AddToCode(String.Format("{0}br label %{2}action{1}\n", MISC.tabsLLVM(depth), GlobalOperatorNumber, type));
                LLVM.AddToCode(String.Format("{0}{2}action{1}:\n", MISC.tabsLLVM(depth - 1), GlobalOperatorNumber, type));
                LLVM.AddToCode(actions.ToLLVM(depth));

                LLVM.AddToCode(String.Format("{0}br label %{2}cond{1}\n", MISC.tabsLLVM(depth), GlobalOperatorNumber, type));
                LLVM.AddToCode(String.Format("{0}{2}cond{1}:\n", MISC.tabsLLVM(depth - 1), GlobalOperatorNumber, type));
                string condLine = condition.getTrueEqual().ToLLVM(depth);
                LLVM.AddToCode(String.Format("{0}br i1 {3}, label %{2}action{1}, label %{2}cont{1}\n", MISC.tabsLLVM(depth), GlobalOperatorNumber, type, condLine));

                LLVM.AddToCode(String.Format("{0}br label %{2}cond{1}\n", MISC.tabsLLVM(depth), GlobalOperatorNumber, type));
                LLVM.AddToCode(String.Format("{0}{2}cont{1}:", MISC.tabsLLVM(depth - 1), GlobalOperatorNumber, type));
            }
            return("");
        }
Ejemplo n.º 6
0
 public CycleWhile(string parseCondition, CommandOrder actions, bool doFirst)
 {
     condition    = new Equal(BinaryOperation.ParseFrom(parseCondition), new ASTvalue(new ValueType(VT.Cboolean), (object)true));
     this.actions = actions;
     this.doFirst = doFirst;
 }