void walkAssignExp(LuaAST assignExp) { LuaAST varlist = assignExp.Components["varlist"]; LuaAST explist = assignExp.Components["explist"]; List <LuaVariable> vl = getVariables(varlist); for (int i = 0; i < vl.Count; i++) { LuaVariable var = vl[i]; if (var != null) { Variable v = new Variable(var.Name); if (i >= explist.ComponentGroup.Count) { continue; } else { v.Type = getExpressionType(explist.ComponentGroup[i]); if (v.Type.InternalName == "(UnknownType)") { continue; } } v.StartPos = var.StartPos; m_currentScope.addVariable(v); } } }
Type getSuffixType(Type t, LuaAST suffix) { if (suffix.Components.ContainsKey("index")) { LuaAST index = suffix.Components["index"]; if (index.Components.ContainsKey("name")) { LuaVariable name = getVariable(index.Components["name"]); if (t.Members.ContainsKey(name.Name)) { return(t.Members[name.Name].Type); } if (t.Methods.ContainsKey(name.Name)) { return(t.Methods[name.Name].ReturnType); } if (t.InnerClasses.ContainsKey(name.Name)) { return(t.InnerClasses[name.Name]); } } } return(t); }
LuaVariable getVariable(LuaAST var) { if (var.Name == "Name") { LuaVariable v = new LuaVariable(); v.Name = Encoding.UTF8.GetString(var.Token.data); v.StartPos = var.start; return(v); } return(null); }
List <LuaVariable> getNamelist(LuaAST namelist) { List <LuaVariable> rst = new List <LuaVariable>(); foreach (LuaAST v in namelist.ComponentGroup) { LuaVariable var = getVariable(v); rst.Add(var); } return(rst); }
LuaFuncName getFuncname(LuaAST funcname) { LuaFuncName rst = new LuaFuncName(); foreach (LuaAST n in funcname.ComponentGroup) { LuaVariable v = getVariable(n); rst.Names.Add(v.Name); } if (funcname.Components.ContainsKey("colonName")) { LuaVariable v = getVariable(funcname.Components["colonName"]); rst.Names.Add(v.Name); rst.isColon = true; } return(rst); }
void walkForExp(LuaAST st) { Scope s = new Scope(); s.StartPos = st.start; s.EndPos = st.end; Scope cs = m_currentScope; cs.addChild(s); m_currentScope = s; { LuaVariable var = getVariable(st.Components["name"]); Variable v = new Variable(var.Name); v.Type = getExpressionType(st.Components["initExp"]);//m_ac.Types.get("object"); v.StartPos = var.StartPos; m_currentScope.addVariable(v); walkChuck(st.Components["block"]); } m_currentScope = cs; }
LuaVariable getVariable(LuaAST var) { if (var.Name == "Name") { LuaVariable v = new LuaVariable(); v.Name = Encoding.UTF8.GetString(var.Token.data); v.StartPos = var.start; return v; } return null; }