Ejemplo n.º 1
0
            public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
            {
                LogicalLine ifJumpto = func.JumpTo;//ENDIF
                //チェック済み
                //if (func.IfCaseList == null)
                //	throw new ExeEE("IFのIF-ELSEIFリストが適正に作成されていない");
                //if (func.JumpTo == null)
                //	throw new ExeEE("IFに対応するENDIFが設定されていない");

                InstructionLine line = null;
                for (int i = 0; i < func.IfCaseList.Count; i++)
                {
                    line = func.IfCaseList[i];
                    if (line.IsError)
                        continue;
                    if (line.FunctionCode == FunctionCode.ELSE)
                    {
                        ifJumpto = line;
                        break;
                    }

                    //ExpressionArgument expArg = (ExpressionArgument)(line.Argument);
                    //チェック済み
                    //if (expArg == null)
                    //	throw new ExeEE("IFチェック中。引数が解析されていない。", func.IfCaseList[i].Position);

                    //1730 ELSEIFが出したエラーがIFのエラーとして検出されていた
                    state.CurrentLine = line;
                    Int64 value = ((ExpressionArgument)(line.Argument)).Term.GetIntValue(exm);
                    if (value != 0)//式が真
                    {
                        ifJumpto = line;
                        break;
                    }
                }
                if (ifJumpto != func)//自分自身がジャンプ先ならそのまま
                    state.JumpTo(ifJumpto);
                //state.RunningLine = null;
            }
Ejemplo n.º 2
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     //if (iFuncCode == FunctionCode.ELSE || iFuncCode == FunctionCode.ELSEIF
     //	|| iFuncCode == FunctionCode.CASE || iFuncCode == FunctionCode.CASEELSE)
     //チェック済み
     //if (func.JumpTo == null)
     //	throw new ExeEE(func.Function.Name + "のジャンプ先が設定されていない");
     state.JumpTo(func.JumpTo);
 }
Ejemplo n.º 3
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     string label = null;
     LogicalLine jumpto = null;
     if (func.Argument.IsConst)
     {
         label = func.Argument.ConstStr;
         jumpto = func.JumpTo;
     }
     else
     {
         label = ((SpCallArgment)func.Argument).FuncnameTerm.GetStrValue(exm);
         if (Config.ICVariable)
             label = label.ToUpper();
         jumpto = state.CurrentCalled.CallLabel(GlobalStatic.Process, label);
     }
     if (jumpto == null)
     {
         if (!func.Function.IsTry())
             throw new CodeEE("指定されたラベル名\"$" + label + "\"は現在の関数内に存在しません");
         if (func.JumpToEndCatch != null)
             state.JumpTo(func.JumpToEndCatch);
         return;
     }
     else if (jumpto.IsError)
         throw new CodeEE("指定されたラベル名\"$" + label + "\"は無効な$ラベル行です");
     state.JumpTo(jumpto);
 }
Ejemplo n.º 4
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     //if (sequential)//上から流れてきたなら何もしないでENDCATCHに飛ぶ
     state.JumpTo(func.JumpToEndCatch);
 }
Ejemplo n.º 5
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     InstructionLine jumpTo = (InstructionLine)func.JumpTo;
     if ((jumpTo.FunctionCode == FunctionCode.REPEAT) || (jumpTo.FunctionCode == FunctionCode.FOR))
     {
         //ループ変数が不明(REPEAT、FORを経由せずにループしようとした場合は無視してループを抜ける(eramakerがこういう仕様だったりする))
         if (jumpTo.LoopCounter == null)
         {
             state.JumpTo(jumpTo.JumpTo);
             return;
         }
         unchecked
         {
             jumpTo.LoopCounter.PlusValue(jumpTo.LoopStep, exm);
         }
         Int64 counter = jumpTo.LoopCounter.GetIntValue(exm);
         //まだ回数が残っているなら、
         if (((jumpTo.LoopStep > 0) && (jumpTo.LoopEnd > counter))
             || ((jumpTo.LoopStep < 0) && (jumpTo.LoopEnd < counter)))
             state.JumpTo(func.JumpTo);
         else
             state.JumpTo(jumpTo.JumpTo);
         return;
     }
     if (jumpTo.FunctionCode == FunctionCode.WHILE)
     {
         if (((ExpressionArgument)jumpTo.Argument).Term.GetIntValue(exm) != 0)
             state.JumpTo(func.JumpTo);
         else
             state.JumpTo(jumpTo.JumpTo);
         return;
     }
     if (jumpTo.FunctionCode == FunctionCode.DO)
     {
         //こいつだけはCONTINUEよりも後ろに判定行があるため、判定行にエラーがあった場合に問題がある
         InstructionLine tFunc = (InstructionLine)((InstructionLine)func.JumpTo).JumpTo;//LOOP
         if (tFunc.IsError)
             throw new CodeEE(tFunc.ErrMes, tFunc.Position);
         ExpressionArgument expArg = (ExpressionArgument)tFunc.Argument;
         if (expArg.Term.GetIntValue(exm) != 0)//式が真
             state.JumpTo(jumpTo);//DO
         else
             state.JumpTo(tFunc);//LOOP
         return;
     }
     throw new ExeEE("異常なCONTINUE");
 }
Ejemplo n.º 6
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     ExpressionArgument expArg = (ExpressionArgument)func.Argument;
     if (expArg.Term.GetIntValue(exm) != 0)//式が真
         return;//そのまま中の処理へ
     state.JumpTo(func.JumpTo);
 }
Ejemplo n.º 7
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     SpCallArgment spCallArg = (SpCallArgment)func.Argument;
     CalledFunction call = null;
     string labelName = null;
     UserDefinedFunctionArgument arg = null;
     if (spCallArg.IsConst)
     {
         call = spCallArg.CallFunc;
         labelName = spCallArg.ConstStr;
         arg = spCallArg.UDFArgument;
     }
     else
     {
         labelName = spCallArg.FuncnameTerm.GetStrValue(exm);
         if (Config.ICFunction)
             labelName = labelName.ToUpper();
         call = CalledFunction.CallFunction(GlobalStatic.Process, labelName, func);
     }
     if (call == null)
     {
         if (!isTry)
             throw new CodeEE("関数\"@" + labelName + "\"が見つかりません");
         if (func.JumpToEndCatch != null)
             state.JumpTo(func.JumpToEndCatch);
         return;
     }
     call.IsJump = isJump;
     if (arg == null)
     {
         string errMes;
         arg = call.ConvertArg(spCallArg.RowArgs, out errMes);
         if (arg == null)
             throw new CodeEE(errMes);
     }
     state.IntoFunction(call, arg, exm);
 }
Ejemplo n.º 8
0
            public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
            {
                LogicalLine caseJumpto = func.JumpTo;//ENDSELECT
                IOperandTerm selectValue = ((ExpressionArgument)func.Argument).Term;
                string sValue = null;
                Int64 iValue = 0;
                if (selectValue.IsInteger)
                    iValue = selectValue.GetIntValue(exm);
                else
                    sValue = selectValue.GetStrValue(exm);
                //チェック済み
                //if (func.IfCaseList == null)
                //	throw new ExeEE("SELECTCASEのCASEリストが適正に作成されていない");
                //if (func.JumpTo == null)
                //	throw new ExeEE("SELECTCASEに対応するENDSELECTが設定されていない");
                InstructionLine line = null;
                for (int i = 0; i < func.IfCaseList.Count; i++)
                {
                    line = func.IfCaseList[i];
                    if (line.IsError)
                        continue;
                    if (line.FunctionCode == FunctionCode.CASEELSE)
                    {
                        caseJumpto = line;
                        break;
                    }
                    CaseArgument caseArg = (CaseArgument)(line.Argument);
                    //チェック済み
                    //if (caseArg == null)
                    //	throw new ExeEE("CASEチェック中。引数が解析されていない。", func.IfCaseList[i].Position);

                    state.CurrentLine = line;
                    if (selectValue.IsInteger)
                    {
                        Int64 Is = iValue;
                        foreach (CaseExpression caseExp in caseArg.CaseExps)
                        {
                            if (caseExp.GetBool(Is, exm))
                            {
                                caseJumpto = line;
                                goto casefound;
                            }
                        }
                    }
                    else
                    {
                        string Is = sValue;
                        foreach (CaseExpression caseExp in caseArg.CaseExps)
                        {
                            if (caseExp.GetBool(Is, exm))
                            {
                                caseJumpto = line;
                                goto casefound;
                            }
                        }
                    }

                }
                casefound:
                state.JumpTo(caseJumpto);
                //state.RunningLine = null;
            }
Ejemplo n.º 9
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     InstructionLine jumpTo = (InstructionLine)func.JumpTo;
     if (((ExpressionArgument)jumpTo.Argument).Term.GetIntValue(exm) != 0)
         state.JumpTo(func.JumpTo);
 }
Ejemplo n.º 10
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     ////BREAKのJUMP先はRENDまたはNEXT。そのジャンプ先であるREPEATかFORをiLineに代入。
     //1.723 仕様変更。BREAKのJUMP先にはREPEAT、FOR、WHILEを記憶する。そのJUMP先が本当のJUMP先。
     InstructionLine jumpTo = (InstructionLine)func.JumpTo;
     InstructionLine iLine = (InstructionLine)jumpTo.JumpTo;
     //WHILEとDOはカウンタがないので、即ジャンプ
     if (jumpTo.FunctionCode != FunctionCode.WHILE && jumpTo.FunctionCode != FunctionCode.DO)
     {
         unchecked
         {//本家ではBREAK時にCOUNTが回る
             jumpTo.LoopCounter.PlusValue(jumpTo.LoopStep, exm);
         }
     }
     state.JumpTo(iLine);
 }
Ejemplo n.º 11
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     state.JumpTo(func.ParentLabelLine);
 }
Ejemplo n.º 12
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     SpForNextArgment forArg = (SpForNextArgment)func.Argument;
     func.LoopCounter = forArg.Cnt;
     //1.725 順序変更。REPEATにならう。
     func.LoopCounter.SetValue(forArg.Start.GetIntValue(exm), exm);
     func.LoopEnd = forArg.End.GetIntValue(exm);
     func.LoopStep = forArg.Step.GetIntValue(exm);
     if ((func.LoopStep > 0) && (func.LoopEnd > func.LoopCounter.GetIntValue(exm)))//まだ回数が残っているなら、
         return;//そのまま次の行へ
     else if ((func.LoopStep < 0) && (func.LoopEnd < func.LoopCounter.GetIntValue(exm)))//まだ回数が残っているなら、
         return;//そのまま次の行へ
     state.JumpTo(func.JumpTo);
 }
Ejemplo n.º 13
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     InstructionLine jumpTo = (InstructionLine)func.JumpTo;
     //ループ変数が不明(REPEAT、FORを経由せずにループしようとした場合は無視してループを抜ける(eramakerがこういう仕様だったりする))
     if (jumpTo.LoopCounter == null)
     {
         state.JumpTo(jumpTo.JumpTo);
         return;
     }
     unchecked
     {
         jumpTo.LoopCounter.PlusValue(jumpTo.LoopStep, exm);
     }
     Int64 counter = jumpTo.LoopCounter.GetIntValue(exm);
     //まだ回数が残っているなら、
     if (((jumpTo.LoopStep > 0) && (jumpTo.LoopEnd > counter))
         || ((jumpTo.LoopStep < 0) && (jumpTo.LoopEnd < counter)))
         state.JumpTo(func.JumpTo);
 }
Ejemplo n.º 14
0
 public override void DoInstruction(ExpressionMediator exm, InstructionLine func, ProcessState state)
 {
     exm.Console.UseUserStyle = !func.Function.IsPrintDFunction();
     //表示データが空なら何もしないで飛ぶ
     if (func.dataList.Count == 0)
     {
         state.JumpTo(func.JumpTo);
         return;
     }
     int count = func.dataList.Count;
     int choice = (int)exm.VEvaluator.GetNextRand(count);
     VariableTerm iTerm = ((PrintDataArgument)func.Argument).Var;
     if (iTerm != null)
     {
         iTerm.SetValue(choice, exm);
     }
     List<InstructionLine> iList = func.dataList[choice];
     int i = 0;
     IOperandTerm term = null;
     string str = null;
     foreach (InstructionLine selectedLine in iList)
     {
         state.CurrentLine = selectedLine;
         if (selectedLine.Argument == null)
             ArgumentParser.SetArgumentTo(selectedLine);
         term = ((ExpressionArgument)selectedLine.Argument).Term;
         str = term.GetStrValue(exm);
         if (func.Function.IsPrintKFunction())
             str = exm.ConvertStringType(str);
         exm.Console.Print(str);
         if (++i < (int)iList.Count)
             exm.Console.NewLine();
     }
     if (func.Function.IsNewLine() || func.Function.IsWaitInput())
     {
         exm.Console.NewLine();
         if (func.Function.IsWaitInput())
             exm.Console.ReadAnyKey();
     }
     exm.Console.UseUserStyle = true;
     //ジャンプするが、流れが連続であることを保証。
     state.JumpTo(func.JumpTo);
     //state.RunningLine = null;
 }