public void VarExp(VarExp e) { switch (e.Pos) { case 0: il.Emit(OpCodes.Ldarg_0); break; case 1: il.Emit(OpCodes.Ldarg_1); break; case 2: il.Emit(OpCodes.Ldarg_2); break; case 3: il.Emit(OpCodes.Ldarg_3); break; default: if (e.Pos > -128 && e.Pos < 127) { il.Emit(OpCodes.Ldarg_S, e.Pos); } else { il.Emit(OpCodes.Ldarg, e.Pos); } break; } }
//通用,完整参数版 public ExpForm(Exp exp, GameEvent gameEvent, bool showThisEvent, TypeDefine requireRetType, VarExp vexp) { this.m_showThisEvent = showThisEvent; this.m_requireRetType = requireRetType; this.VExp = vexp; ExpForm_Show(exp, gameEvent); }
Exp analyParentClass(AnalyExpContext context) { ClassContext classContext = context.ClassContext; SymbolDefClass classSymbol = classContext.ClassSymbol; if (classSymbol.BaseGcl == null) { return(null); } ExPropertyInfo property = classSymbol.BaseGcl.SearchExProperty(IdentName); //if (property == null) return null; if (property != null) { if (ReflectionUtil.IsPublic(property.Property) || ReflectionUtil.IsProtected(property.Property)) { SymbolDefProperty ps = new SymbolDefProperty(IdentName, property.Property.PropertyType, ReflectionUtil.IsStatic(property.Property)); ps.SetProperty(property.Property); VarExp exp = new VarExp(this, this.IdentToken); exp.VarSymbol = ps; return(exp); } } return(null); }
void analyFields(bool isStatic) { Fields = new Dictionary <string, SymbolDefField>(); var symbols = NestedClassContext.Symbols; var names = FieldExps.Keys.ToList(); for (int i = 0; i < names.Count; i++) { var name = names[i]; VarExp exp = FieldExps[name]; SymbolVar symbol = exp.VarSymbol as SymbolVar; //if (symbol is InstanceSymbol) //{ var propertyType = symbol.DimType; FieldBuilder field = NestedClassContext.EmitContext.CurrentTypeBuilder.DefineField("_" + name, propertyType, FieldAttributes.Public); SymbolDefField fieldSymbol = new SymbolDefField(name, propertyType, isStatic); fieldSymbol.SetField(field); symbols.AddSafe(fieldSymbol); //Fields.Remove(name); Fields.Add(name, fieldSymbol); exp.IsNestedField = true; SymbolDefField fs = new SymbolDefField(name, field.FieldType, field.IsStatic); fs.SetField(field); exp.VarSymbol = fs; //nestedSymbolInfos.Add(fieldSymbol); //} } }
void GenenrateSubject(EmitExpContext context) { ILGenerator il = context.ILout; bool isgen = false; if ((SubjectExp is VarExp)) { VarExp varexp = SubjectExp as VarExp; if (ReflectionUtil.IsStruct(varexp.RetType)) { if (varexp.VarSymbol is SymbolVar) { il.Emit(OpCodes.Ldloca, (varexp.VarSymbol as SymbolVar).VarBuilder); isgen = true; } else if (varexp.VarSymbol is SymbolArg) { il.Emit(OpCodes.Ldarga, (varexp.VarSymbol as SymbolArg).ArgIndex); isgen = true; } } } if (!isgen) { SubjectExp.Generate(context); } }
public override object Clone() { VarExp e = new VarExp(); e.ReturnType = this.ReturnType; e.strText = this.strText; return(e); }
public override Exp Analy( ) { //if (IsAnalyed) return this; Exp newExp = VarExp.Analy(); VarExp = newExp; this.AnalyCorrect = true; RetType = VarExp.RetType; return(this); }
public Exp Parse(Token identToken, Exp srcExp) { sourceToken = identToken; i = 0; code = this.sourceToken.GetText(); if (code.IndexOf('的') == -1 && code.IndexOf('第') == -1) { return(null); } Exp exp = parseIdentExp(); while (i < code.Length /*&& code[i] == '的'*/) { char ch = code[i]; if (ch == '的') { i++; DeExp expDe = new DeExp(); expDe.SubjectExp = exp; Token token = parseToken(); expDe.MemberToken = token; exp = expDe; } else if (ch == '第') { i++; DiExp expDi = new DiExp(srcExp); expDi.SubjectExp = exp; Token token = parseToken(); if (token != null) { if (TextUtil.IsInt(token.GetText())) { token.Kind = TokenKind.LiteralInt; LiteralExp expLiteral = new LiteralExp(); expLiteral.LiteralToken = token; expDi.ArgExp = expLiteral; } else { token.Kind = TokenKind.Ident; //IdentExp expIdent = new IdentExp(); //expIdent.IsFinally = true; VarExp varExp = new VarExp(srcExp, token); //varExp.VarToken = token; expDi.ArgExp = varExp; } } exp = expDi; } i++; } return(exp); }
public void VarExp(VarExp e) { if (CurrentFuncDef[e.Name] != null) { e.ExpType = (Type)CurrentFuncDef[e.Name]; } else { e.ExpType = typeof(void); } }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (!(obj is VarExp)) { return(false); } VarExp exp = obj as VarExp; if (this.strText != exp.strText) { return(false); } //if (this.ReturnType == null || exp.ReturnType == null) return true; return(this.ReturnType.DBID == exp.ReturnType.DBID); }
Exp analyCurrentClass(AnalyExpContext context) { var IdentSymbol = symbols.Get(IdentName); if (IdentSymbol == null) { return(null); } if (IdentSymbol is InstanceSymbol) { VarExp exp = new VarExp(this, IdentToken, this.IsAssignedBy, this.IsAssignedValue); return(exp); } else if (IdentSymbol is SymbolDefClass) { TypeExp exp = new TypeExp(this, IdentToken, (IdentSymbol as SymbolDefClass)); return(exp); } else { throw new CompileException("类型非IVarSymbol、SymbolDefClass"); } }
public void ExpForm_Show(Exp exp, GameEvent gameEvent) { System.Diagnostics.Debug.Assert(exp != null); System.Diagnostics.Debug.Assert(gameEvent != null); InitializeComponent(); this.expControl1.VExp = this.VExp; enableAPIListChange = false; this.m_eventDefine = gameEvent; this.m_exp = exp.Clone() as Exp; if (exp.ReturnType == null) { this.Text = "任意表达式"; } else { this.Text = exp.ReturnType.ToString() + " 表达式"; } this.DialogResult = DialogResult.Cancel; // 刷新功能列表 GameAPIDefine[] ret; if (this.m_requireRetType == null) // 表达式类型未知,用于条件判断中输入未知类型的节点用。 { // 获取所有有返回值的API // ret = ExpManager.GetAPIDefineListExceptReturnType(TypeDefine.NilType); 如果只能选有返回值的API的话,那么几乎每个有返回值API都要做一个无返回值的版本才能在动作组里没选到, // 这样会带来很大的维护工作量,所以修正为可以选择所有的API。 ret = ExpManager.GetAPIDefine_All(); this.radioConst.Enabled = false; this.radioConstSel.Enabled = false; this.comboBoxConst.Enabled = false; this.txtConst.Enabled = false; this.btnSelect.Enabled = false; this.comboBoxAPI.TabIndex = 2; } else { // 专用API列出来 ret = ExpManager.GetAPIDefineByReturnType(exp.ReturnType); } if (ret != null) { comboBoxAPI.Items_AddRange(Helper.SortByToString(ret)); } // 刷新常数列表 if (exp.ReturnType != null) { if (exp.ReturnType.isEnum) { this.txtConst.Enabled = false; this.radioConst.Enabled = false; ConstExp[] const_ret = ExpManager.GetConstExpByReturnType(exp.ReturnType); if (const_ret != null) { comboBoxConst.Items.AddRange(const_ret); } if (comboBoxConst.Items.Count > 0) { comboBoxConst.SelectedItem = comboBoxConst.Items[0]; } if (!exp.ReturnType.ContainsValueEdit) { this.btnSelect.Enabled = false; } } else { this.comboBoxConst.Enabled = false; this.radioConstSel.Enabled = false; this.btnSelect.Enabled = false; if (exp.ReturnType.ContainsValueEdit) { this.btnInput.Enabled = true; } } } //刷新本事件列表 if (this.m_showThisEvent) { for (int i = 0; i < gameEvent.ArgList.Length; i++) { if (exp.ReturnType == null || gameEvent.ArgList[i].ArgType.DBID == exp.ReturnType.DBID) { comboBoxEventArg.Items.Add(gameEvent.GetArgExp(i + 1)); } if (comboBoxEventArg.Items.Count > 0) { comboBoxEventArg.SelectedItem = comboBoxEventArg.Items[0]; } } //对任意类型的支持,在这里可以选到 if (this.VExp != null) { if (exp.ReturnType == null || this.VExp.ReturnType == null || this.VExp.ReturnType.DBID == exp.ReturnType.DBID) { comboBoxEventArg.Items.Add(this.VExp); } } } //灰掉某些东东 if (comboBoxAPI.Items_Count == 0) { //灰掉API comboBoxAPI.Enabled = false; radioExp.Enabled = false; } //灰掉常数 if (comboBoxConst.Items.Count == 0)// && exp.ReturnType.m_isEnum) { comboBoxConst.Enabled = false; } if (exp.ReturnType == null || !exp.ReturnType.isDuplicate) { txtConst.Enabled = false; } if (txtConst.Enabled == false && comboBoxConst.Enabled == false) { radioConst.Enabled = false; } //灰掉本事件 if (comboBoxEventArg.Items.Count == 0) { comboBoxEventArg.Enabled = false; radioEventArg.Enabled = false; } //自动选中API if (m_exp is ActionExp) { foreach (GameAPIDefine apidefine in comboBoxAPI.Items_All) { if (apidefine.DBID == (m_exp as ActionExp).API.DBID) { this.comboBoxAPI.Text = apidefine.ToString() + " "; //this.comboBoxAPI.Items; break; } } this.expControl1.SetComboText(m_exp as ActionExp, this.m_eventDefine); this.expControl1.VExp = this.VExp; this.radioExp.Checked = true; //this.expControl1.Focus(); this.m_FousedControl = this.expControl1; } //自动选中常数 if (m_exp is ConstExp) { ConstExp conExp = m_exp as ConstExp; if (conExp.ReturnType.isEnum) { if (conExp.ReturnType.ContainsValueEdit) //使用lua脚本编辑 { this.comboBoxConst.Items.Clear(); this.comboBoxConst.Items.Add(conExp); this.comboBoxConst.SelectedItem = conExp; //this.comboBoxConst.Enabled = true; } else //使用下拉菜单编辑 { foreach (ConstExp ex in comboBoxConst.Items) { if (ex.DBValue == conExp.DBValue) { this.comboBoxConst.SelectedItem = ex; break; } } if (this.comboBoxConst.SelectedItem == null && comboBoxConst.Items.Count > 0) { comboBoxConst.SelectedItem = comboBoxConst.Items[0]; } } this.radioConstSel.Checked = true; this.m_FousedControl = this.radioConstSel; } else { this.txtConst.Text = m_exp.strText; this.radioConst.Checked = true; //this.radioConst.Focus(); //this.txtConst.Focus(); this.m_FousedControl = this.txtConst; } } //自动选中本事件 if (m_exp is ObjectExp) { ObjectExp oExp = m_exp as ObjectExp; foreach (ObjectExp ex in comboBoxEventArg.Items) { if (ex.AsEventArgPos == oExp.AsEventArgPos) { this.comboBoxEventArg.SelectedItem = ex; break; } } this.radioEventArg.Checked = true; //this.comboBoxEventArg.Focus(); this.m_FousedControl = this.comboBoxEventArg; } //自动选中无类型变量 if (m_exp is VarExp) { foreach (Exp ex in comboBoxEventArg.Items) { if (ex is VarExp) { this.comboBoxEventArg.SelectedItem = ex; } } this.radioEventArg.Checked = true; this.m_FousedControl = this.comboBoxEventArg; } if (!this.radioConst.Checked && !this.radioEventArg.Checked && !this.radioEventArg.Checked && !this.radioExp.Checked) { this.radioConst.Checked = true; this.m_FousedControl = txtConst; } enableAPIListChange = true; this.comboBoxAPI.SelectedIndexChanged += new System.EventHandler(this.comboBoxAPI_SelectedIndexChanged); }
Exp dimVar(AnalyExpContext context) { VarExp varexp = new VarExp(this, IdentToken, this.IsAssignedBy, this.IsAssignedValue); return(varexp); }
public override string ToString() { return("( " + VarExp.ToString() + " )"); }
public override void Emit() { VarExp.Emit(); }