private void Parse_SwitchStmt() { int label = base.NewLabel(); int num2 = base.NewLabel(); IntegerList list = new IntegerList(true); IntegerList list2 = new IntegerList(true); IntegerStack stack = new IntegerStack(); int num3 = base.NewVar(); this.Gen(base.code.OP_ASSIGN, num3, base.TRUE_id, num3); base.BreakStack.Push(label); this.Match("switch"); base.BeginBlock(); this.Match('('); int num4 = this.Parse_Expression(); this.Match(')'); this.Match('{'); Label_008D: if (base.IsCurrText("case")) { this.Match("case"); stack.Push(base.NewLabel()); int avalue = this.Parse_Expression(); list.AddObject(avalue, stack.Peek()); this.Gen(base.code.OP_EQ, num4, avalue, num3); this.Gen(base.code.OP_GO_TRUE, stack.Peek(), num3, 0); } else { if (!base.IsCurrText("default")) { while (stack.Count > 0) { base.SetLabelHere(stack.Peek()); stack.Pop(); } int num6 = base.NewLabel(); this.Gen(base.code.OP_GO_FALSE, num6, num3, 0); while ((!base.IsCurrText("case") && !base.IsCurrText("default")) && !base.IsCurrText('}')) { if (base.IsCurrText("goto")) { this.Match("goto"); if (base.IsCurrText("case")) { this.Match("case"); int num7 = this.Parse_Expression(); this.Gen(base.code.OP_GOTO_START, 0, 0, 0); list2.AddObject(num7, base.CodeCard); this.Match(';'); } else if (base.IsCurrText("default")) { this.Match("default"); this.Gen(base.code.OP_GOTO_START, num2, 0, 0); this.Match(';'); } else { int num8 = this.Parse_Ident(); this.Gen(base.code.OP_GOTO_START, num8, 0, 0); this.Match(';'); } } else { this.Parse_Stmt(); } } base.SetLabelHere(num6); if (base.IsCurrText('}')) { base.BreakStack.Pop(); base.SetLabelHere(label); base.EndBlock(); this.Match('}'); for (int i = 0; i < list2.Count; i++) { int id = list2[i]; int n = (int) list2.Objects[i]; object val = base.GetVal(id); bool flag = false; for (int j = 0; j < list.Count; j++) { int num13 = list[j]; int num14 = (int) list.Objects[j]; object obj3 = base.GetVal(num13); if ((val.GetType() == obj3.GetType()) && (val == obj3)) { flag = true; base.GenAt(n, base.code.OP_GOTO_START, num14, 0, 0); break; } } if (!flag) { base.CodeCard = n; base.RaiseErrorEx(true, "CS0159. No such label '{0}' within the scope of the goto statement.", new object[] { val.ToString() }); } } return; } goto Label_008D; } this.Match("default"); base.SetLabelHere(num2); this.Gen(base.code.OP_ASSIGN, num3, base.TRUE_id, num3); } this.Match(':'); goto Label_008D; }
public void ProcessEvalOp(IntegerStack l) { bool upcase = this.GetUpcase(); int nameIndex = this.symbol_table[this.r.res].NameIndex; int res = this.r.res; string name = this.symbol_table[res].Name; MemberObject memberByNameIndex = null; for (int i = l.Count - 1; i >= 0; i--) { MemberObject memberObject = this.GetMemberObject(l[i]); memberByNameIndex = memberObject.GetMemberByNameIndex(nameIndex, upcase); if ((memberByNameIndex != null) && ((memberByNameIndex.Kind != MemberKind.Constructor) || (i == (l.Count - 1)))) { int id = l.Peek(); MemberObject obj4 = this.GetMemberObject(id); if (obj4.Static) { if (memberByNameIndex.Static) { this.r.op = this.OP_NOP; this.ReplaceIdEx(this.r.res, memberByNameIndex.Id, this.n, true); break; } if (this.GetCurrentClass(l).IsOuterMemberId(memberByNameIndex.Id)) { this.scripter.CreateErrorObjectEx("CS0038. Cannot access a nonstatic member of outer type '{0}' via nested type '{1}'.", new object[] { memberObject.Name, this.GetCurrentClass(l).Name }); break; } memberByNameIndex = null; } else { if (memberByNameIndex.Static) { this.r.op = this.OP_NOP; this.ReplaceIdEx(this.r.res, memberByNameIndex.Id, this.n, true); } else if (this.GetCurrentClass(l).IsOuterMemberId(memberByNameIndex.Id)) { this.scripter.CreateErrorObjectEx("CS0038. Cannot access a nonstatic member of outer type '{0}' via nested type '{1}'.", new object[] { memberObject.Name, this.GetCurrentClass(l).Name }); } else if (obj4.Kind == MemberKind.Type) { this.r.op = this.OP_NOP; } else { FunctionObject obj5 = (FunctionObject) obj4; this.r.op = this.OP_CREATE_REFERENCE; this.r.arg1 = obj5.ThisId; this.symbol_table[this.r.res].Level = this.r.arg1; this.symbol_table[this.r.res].Kind = MemberKind.Ref; this.symbol_table[this.r.res].TypeId = this.symbol_table[memberByNameIndex.Id].TypeId; } break; } } } if (memberByNameIndex == null) { memberByNameIndex = this.FindType(l, name, upcase); if (memberByNameIndex != null) { this.r.op = this.OP_NOP; this.ReplaceIdEx(this.r.res, memberByNameIndex.Id, this.n, true); } else if (this.symbol_table[res].Kind == MemberKind.Label) { int num5 = this.EvalLabel(res); if (num5 == 0) { this.scripter.CreateErrorObjectEx("Undeclared identifier '{0}'", new object[] { name }); } else { this.r.op = this.OP_NOP; this.ReplaceIdEx(this.r.res, num5, this.n, true); } } else { bool flag2 = false; if (!this.GetExplicit(this.n)) { int level = this.symbol_table[this.r.res].Level; if ((this[this.n + 1].op == this.OP_ASSIGN) && (this[this.n + 1].arg1 == this.r.res)) { this.r.op = this.OP_DECLARE_LOCAL_VARIABLE; this.r.arg1 = this.r.res; this.r.arg2 = level; flag2 = true; } else { string str2 = this.symbol_table[this.r.res].Name; for (int j = this.n; j >= 1; j--) { if (this[j].op == this.OP_DECLARE_LOCAL_VARIABLE) { if (this[j].arg2 != level) { break; } int num8 = this[j].arg1; string str3 = this.symbol_table[num8].Name; if (CSLite_System.CompareStrings(str2, str3, upcase)) { this.r.op = this.OP_NOP; this.ReplaceId(this.r.res, num8); flag2 = true; break; } } } } } if (!flag2) { if (this.PascalOrBasic(this.n)) { for (int k = 1; k <= this.card; k++) { if (this[k].op == this.OP_CREATE_CLASS) { ClassObject classObject = this.GetClassObject(this[k].arg1); if (classObject.Static) { memberByNameIndex = classObject.GetMemberByNameIndex(nameIndex, upcase); if (memberByNameIndex != null) { this.r.op = this.OP_NOP; this.ReplaceId(this.r.res, memberByNameIndex.Id); return; } } } } } if (this.scripter.DefaultInstanceMethods) { foreach (string str4 in this.scripter.UserInstances.Keys) { Type t = this.scripter.UserInstances[str4].GetType(); foreach (MethodInfo info in t.GetMethods()) { if (!CSLite_System.CompareStrings(name, info.Name, upcase)) { continue; } int num10 = 0; for (int m = 1; m <= this.symbol_table.Card; m++) { if (((this.symbol_table[m].Level == 0) && (this.symbol_table[m].Kind == MemberKind.Var)) && (CSLite_System.CompareStrings(this.symbol_table[m].Name, str4, upcase) && (this.symbol_table[m].Val != null))) { num10 = m; break; } } if (num10 != 0) { int num12 = this.symbol_table.RegisterType(t, false); this.r.op = this.OP_CREATE_REFERENCE; this.r.arg1 = num10; this.symbol_table[this.r.res].Level = this.r.arg1; this.symbol_table[this.r.res].Kind = MemberKind.Ref; this.symbol_table[this.r.res].TypeId = num12; return; } } foreach (PropertyInfo info2 in t.GetProperties()) { if (!CSLite_System.CompareStrings(name, info2.Name, upcase)) { continue; } int num13 = 0; for (int n = 1; n <= this.symbol_table.Card; n++) { if (((this.symbol_table[n].Level == 0) && (this.symbol_table[n].Kind == MemberKind.Var)) && (CSLite_System.CompareStrings(this.symbol_table[n].Name, str4, upcase) && (this.symbol_table[n].Val != null))) { num13 = n; break; } } if (num13 != 0) { int num15 = this.symbol_table.RegisterType(t, false); this.r.op = this.OP_CREATE_REFERENCE; this.r.arg1 = num13; this.symbol_table[this.r.res].Level = this.r.arg1; this.symbol_table[this.r.res].Kind = MemberKind.Ref; this.symbol_table[this.r.res].TypeId = num15; return; } } } } this.scripter.CreateErrorObjectEx("Undeclared identifier '{0}'", new object[] { name }); } } } }