public FirstPass(ASTNode treeNode, ScopeManager mgr) { _treeNode = treeNode; _scopeMgr = mgr; if (!_scopeMgr.CurrentScope.HasSymbol(GlobalScopeName)) { TypeClass globalClass = new TypeClass(GlobalScopeName); globalClass.Descriptor = _scopeMgr.AddClass(globalClass.ClassName, globalClass, null); //setup built in system methods foreach (SystemMethod m in SystemMethodManager.Methods()) { m.FuncInfo.Scope = _scopeMgr.TopScope; _scopeMgr.AddMethod(m.Name, m.FuncInfo, globalClass, null, true); } } }
public override void VisitInvoke(ASTInvoke n) { if (SystemMethodManager.IsSystemMethod(n.Method)) { n.Actuals.Visit(this); SystemMethod method = SystemMethodManager.Lookup(n.Method); method.Emit(_gen); //store the return type so we can invoke methods and stuff on it. _lastWalkedType = _typeManager.LookupCilType(method.FuncInfo.ReturnType); } else { //push who n.Object.Visit(this); Type who = _lastWalkedType; //push actuals n.Actuals.Visit(this); //find the method to execute on the given class MethodBuilderInfo info = _typeManager.GetMethodBuilderInfo(who.Name, n.Method); _gen.Emit(OpCodes.Callvirt, info.Builder); //store the return type of the method _lastWalkedType = info.Builder.ReturnType; } }
public ThirdPass(ASTNode treeNode, ScopeManager mgr) : base(treeNode, mgr) { _systemMethods = SystemMethodManager.Methods().ToList(); }