public TempCondition(Script script, CodeObject allow, ScriptExecutable executable, Executable_Block block) { m_Script = script; this.Allow = allow; this.Executable = executable; this.Block = block; }
public CodeMember(string name, CodeObject parent) { this.Parent = parent; this.MemberString = name; this.Type = MEMBER_TYPE.STRING; }
public TableVariable(object key, CodeObject value) { this.key = key; this.value = value; }
public ScriptInstruction(Opcode opcode, CodeObject operand0, CodeObject operand1) { Opcode = opcode; Operand0 = operand0; Operand1 = operand1; }
public ScriptExecutable Executable; //指令列表 #endregion Fields #region Constructors public TempCondition(Script script, CodeObject allow, ScriptExecutable executable, Executable_Block block) { this.Allow = allow; this.Executable = executable; this.Context = new ScriptContext(script, executable, null, block); }
private ScriptObject ResolveOperand_impl(CodeObject value) { if (value is CodeScriptObject) { return ParseScriptObject((CodeScriptObject)value); } else if (value is CodeRegion) { return ParseRegion((CodeRegion)value); } else if (value is CodeFunction) { return ParseFunction((CodeFunction)value); } else if (value is CodeCallFunction) { return ParseCall((CodeCallFunction)value, true); } else if (value is CodeMember) { return GetVariable((CodeMember)value); } else if (value is CodeArray) { return ParseArray((CodeArray)value); } else if (value is CodeTable) { return ParseTable((CodeTable)value); } else if (value is CodeOperator) { return ParseOperate((CodeOperator)value); } else if (value is CodeTernary) { return ParseTernary((CodeTernary)value); } else if (value is CodeAssign) { return ParseAssign((CodeAssign)value); } else if (value is CodeEval) { return ParseEval((CodeEval)value); } return m_script.Null; }
private void InvokeContinue(CodeObject con) { m_Continue = true; if (!SupportContinue()) { if (m_parent == null) throw new ExecutionException(m_script, "当前模块不支持continue语法"); m_parent.InvokeContinue(con); } }
//返回变量数据 private CodeObject GetVariable(CodeObject parent) { CodeObject ret = parent; for ( ; ; ) { Token m = ReadToken(); if (m.Type == TokenType.Period) { ret = new CodeMember(ReadIdentifier(), ret); } else if (m.Type == TokenType.LeftBracket) { CodeObject member = GetObject(); ReadRightBracket(); if (member is CodeScriptObject) { ScriptObject obj = ((CodeScriptObject)member).Object; if (member.Not) { ret = new CodeMember(!obj.LogicOperation(), ret); } else if (member.Negative) { ScriptNumber num = obj as ScriptNumber; if (num == null) throw new ParserException("Script Object Type [" + obj.Type + "] is cannot use [-] sign", m); ret = new CodeMember(num.Negative().KeyValue, ret); } else { ret = new CodeMember(obj.KeyValue, ret); } } else { ret = new CodeMember(member, ret); } } else if (m.Type == TokenType.LeftPar) { UndoToken(); ret = GetFunction(ret); } else { UndoToken(); break; } ret.StackInfo = new StackInfo(m_strBreviary, m.SourceLine); } return ret; }
public CodeMember(object value, CodeObject parent) { this.Parent = parent; this.MemberValue = value; this.Type = MEMBER_TYPE.VALUE; }
public CodeMember(CodeObject member, CodeObject parent) { this.MemberObject = member; this.Parent = parent; this.Type = MEMBER_TYPE.OBJECT; }
public CodeCallFunction(CodeObject member, List<CodeObject> parameters) { this.Member = member; this.Parameters = parameters.ToArray(); this.ParametersCount = parameters.Count; }
public CodeObject Context; //变量 public CodeRegion(CodeObject Context) { this.Context = Context; }
public TokenType Operator; //符号类型 public CodeOperator(CodeObject Right, CodeObject Left, TokenType type, string breviary, int line) : base(breviary, line) { this.Left = Left; this.Right = Right; this.Operator = type; }
//解析单纯for循环 private void ParseFor_Simple(string Identifier, CodeObject obj) { CodeForSimple ret = new CodeForSimple(); ret.Identifier = Identifier; ret.Begin = obj; ret.Finished = GetObject(); if (PeekToken().Type == TokenType.Comma) { ReadToken(); ret.Step = GetObject(); } ReadRightParenthesis(); ret.BlockExecutable = ParseStatementBlock(Executable_Block.For); m_scriptExecutable.AddScriptInstruction(new ScriptInstruction(Opcode.CALL_FORSIMPLE, ret)); }
//返回变量数据 private CodeObject GetVariable(CodeObject parent) { CodeObject ret = parent; for ( ; ; ) { Token m = ReadToken(); if (m.Type == TokenType.Period) { string identifier = ReadIdentifier(); ret = new CodeMember(identifier, ret); } else if (m.Type == TokenType.LeftBracket) { CodeObject member = GetObject(); ReadRightBracket(); if (member is CodeScriptObject) { ScriptObject obj = ((CodeScriptObject)member).Object; if (obj is ScriptNumber || obj is ScriptString) ret = new CodeMember(obj.ObjectValue, ret); else throw new ParserException("获取变量只能是 number或string", m); } else { ret = new CodeMember(member, ret); } } else if (m.Type == TokenType.LeftPar) { UndoToken(); ret = GetFunction(ret); } else { UndoToken(); break; } ret.StackInfo = new StackInfo(m_strBreviary, m.SourceLine); } return ret; }
//返回一个调用函数 Object private CodeCallFunction GetFunction(CodeObject member) { ReadLeftParenthesis(); List<CodeObject> pars = new List<CodeObject>(); Token token = PeekToken(); while (token.Type != TokenType.RightPar) { pars.Add(GetObject()); token = PeekToken(); if (token.Type == TokenType.Comma) ReadComma(); else if (token.Type == TokenType.RightPar) break; else throw new ParserException("Comma ',' or right parenthesis ')' expected in function declararion.", token); } ReadRightParenthesis(); return new CodeCallFunction(member, pars); }
public CodeCallFunction(CodeObject member, List <CodeObject> parameters) { this.Member = member; this.Parameters = parameters.ToArray(); this.ParametersCount = parameters.Count; }
private void InvokeBreak(CodeObject bre) { m_Break = true; if (!SupportBreak()) { if (m_parent == null) throw new ExecutionException(m_script, "当前模块不支持break语法"); m_parent.InvokeBreak(bre); } }
ScriptObject ResolveOperand(CodeObject value) { m_script.SetStackInfo(value.StackInfo); ScriptObject ret = ResolveOperand_impl(value); if (value.Not) { ret = m_script.CreateBool(!ret.LogicOperation()); } else if (value.Negative) { ScriptNumber b = ret as ScriptNumber; if (b == null) throw new ExecutionException(m_script, "Script Object Type [" + ret.Type + "] is cannot use [-] sign"); ret = b.Negative(); } return ret; }
public ScriptInstruction(Opcode opcode, CodeObject operand0) : this(opcode, operand0, null) { }
public CodeAssign(CodeMember member, CodeObject value, TokenType assignType, string breviary, int line) : base(breviary, line) { this.member = member; this.value = value; this.AssignType = assignType; }
public CodeObject Context; //变量 #endregion Fields #region Constructors public CodeRegion(CodeObject Context) { this.Context = Context; }