void ProcessCallSwitch() { CodeSwitch code = (CodeSwitch)m_scriptInstruction.Operand0; ScriptObject obj = ResolveOperand(code.Condition); bool exec = false; foreach (TempCase Case in code.Cases) { foreach (CodeObject allow in Case.Allow) { if (ResolveOperand(allow).Equals(obj)) { exec = true; new ScriptContext(m_script, Case.Executable, this, Executable_Block.Switch).Execute(); break; } } if (exec) { break; } } if (exec == false && code.Default != null) { new ScriptContext(m_script, code.Default.Executable, this, Executable_Block.Switch).Execute(); } }
void ProcessCallSwitch() { CodeSwitch code = (CodeSwitch)m_scriptInstruction.Operand0; ScriptObject obj = ResolveOperand(code.Condition); bool exec = false; foreach (TempCase c in code.Cases) { foreach (object a in c.Allow) { if (a.Equals(obj.ObjectValue)) { exec = true; c.Context.Initialize(this); c.Context.Execute(); break; } } } if (exec == false && code.Default != null) { code.Default.Context.Initialize(this); code.Default.Context.Execute(); } }
private void ProcessCallSwitch() { CodeSwitch switch2 = (CodeSwitch)this.m_scriptInstruction.operand0; ScriptObject obj2 = this.ResolveOperand(switch2.Condition); bool flag = false; foreach (TempCase @case in switch2.Cases) { foreach (CodeObject obj3 in @case.Allow) { if (this.ResolveOperand(obj3).Equals(obj2)) { flag = true; new ScriptContext(this.m_script, @case.Executable, this, Executable_Block.Switch).Execute(); break; } } if (flag) { break; } } if (!flag && (switch2.Default != null)) { new ScriptContext(this.m_script, switch2.Default.Executable, this, Executable_Block.Switch).Execute(); } }
private void ParseSwtich() { Token token; CodeSwitch switch2 = new CodeSwitch(); this.ReadLeftParenthesis(); switch2.Condition = this.GetObject(); this.ReadRightParenthesis(); this.ReadLeftBrace(); List <TempCase> cases = new List <TempCase>(); Label_002A: token = this.ReadToken(); if (token.Type == Scorpio.Compiler.TokenType.Case) { List <CodeObject> allow = new List <CodeObject>(); this.ParseCase(allow); cases.Add(new TempCase(this.m_script, allow, this.ParseStatementBlock(Executable_Block.Switch, false, Scorpio.Compiler.TokenType.Break))); goto Label_002A; } if (token.Type == Scorpio.Compiler.TokenType.Default) { this.ReadColon(); switch2.Default = new TempCase(this.m_script, null, this.ParseStatementBlock(Executable_Block.Switch, false, Scorpio.Compiler.TokenType.Break)); goto Label_002A; } if (token.Type == Scorpio.Compiler.TokenType.SemiColon) { goto Label_002A; } this.UndoToken(); this.ReadRightBrace(); switch2.SetCases(cases); this.m_scriptExecutable.AddScriptInstruction(new ScriptInstruction(Opcode.CALL_SWITCH, switch2)); }
//解析swtich语句 private void ParseSwtich() { CodeSwitch ret = new CodeSwitch(); ReadLeftParenthesis(); ret.Condition = GetObject(); ReadRightParenthesis(); ReadLeftBrace(); List <TempCase> Cases = new List <TempCase>(); for (; ;) { Token token = ReadToken(); if (token.Type == TokenType.Case) { List <CodeObject> allow = new List <CodeObject>(); ParseCase(allow); Cases.Add(new TempCase(m_script, allow, ParseStatementBlock(Executable_Block.Switch, false, TokenType.Break))); } else if (token.Type == TokenType.Default) { ReadColon(); ret.Default = new TempCase(m_script, null, ParseStatementBlock(Executable_Block.Switch, false, TokenType.Break)); } else if (token.Type != TokenType.SemiColon) { UndoToken(); break; } } ReadRightBrace(); ret.SetCases(Cases); m_scriptExecutable.AddScriptInstruction(new ScriptInstruction(Opcode.CALL_SWITCH, ret)); }