コード例 #1
0
ファイル: Block.cs プロジェクト: chxb1987/gskRobot
 public string runCode(ref int line, int dir, List <Token> curPara)
 {
     return(compoundStatment.runCode(ref line, dir, curPara));
 }
コード例 #2
0
ファイル: GSKInterpreter.cs プロジェクト: chxb1987/gskRobot
        //运行
        public string runCode(ref int line, int dir)
        {
            tmpLine = line;
            string result = "END";

            //Debug.Log(program.runCode(line));
            if (line >= orderList.Count || line < 0)
            {
                return(result);
            }
            result = program.runCode(ref line, dir, curPara);

            dataInfo.Clear();
            foreach (Token t in curPara)
            {
                dataInfo.Add(t.value());
            }
            switch (result)
            {
            case "MOVJ":
            case "MOVL":
            case "MOVC":
                if (curPara[0].type() == TokenType.PID)
                {
                    pathData = pointTable[int.Parse(dataInfo[0])];
                }
                else
                {
                    pathData = switchToArray(dataInfo[0]);
                }
                if (result == "MOVC")
                {
                    setMovcData(tmpLine);
                }
                break;

            case "DIN":
                if (curPara[0].type() == TokenType.BNUM)
                {
                    varBool[int.Parse(dataInfo[0])] = intToBool(inState[int.Parse(dataInfo[1])]);
                }
                else if (curPara[0].type() == TokenType.RNUM)
                {
                    varR[int.Parse(dataInfo[0])] = int.Parse(dataInfo[1]);
                }
                else
                {
                    inState[int.Parse(dataInfo[0])] = boolToInt(dataInfo[1]);
                }
                break;

            case "DOUT":
                outState[int.Parse(dataInfo[0])] = boolToInt(dataInfo[1]);
                break;

            case "WAIT":
                setWait();
                break;

            case "PALINI":
                iniStack();
                break;

            case "SET":
                iniVar();
                break;

            case "PALFULL":
                fullStack();
                break;

            case "INC":
                incVarI();
                break;

            case "PALPRED":
                setStackPoint(0);
                break;

            case "PALPREU":
                setStackPoint(2);
                break;

            case "PALTO":
                setStackPoint(1);
                break;

            case "PALENT":
                setStackEntPoint();
                break;

            case "SHIFTON":
                GSKDATA.SHIFT    = true;
                GSKDATA.SHIFT_PX = readPX(dataInfo[0]);
                break;

            case "SHIFTOFF":
                GSKDATA.SHIFT = false;
                break;
            }

            return(result);
        }