public override IList <FunctionInfo> InferMethods(SymbolId name) { Initialize(); List <ReflectedMember> list; IList <FunctionInfo> result = null; if (members.TryGetValue(name, out list)) { foreach (ReflectedMember member in list) { ReflectedMethod method = member as ReflectedMethod; if (null != method) { result = Engine.Union <FunctionInfo>(result, method.InferMethods(name)); } } } else if (type.Name == name.GetString()) { members.TryGetValue(SymbolTable.StringToId(".ctor"), out list); foreach (ReflectedMember member in list) { ReflectedConstructor constructor = member as ReflectedConstructor; if (constructor != null) { result = Engine.Union <FunctionInfo>(result, constructor.InferMethods(name)); } } } return(result); }
public IList <Inferred> ResolveCurrent(SymbolId name, Engine engine) { List <Definition> defs; IList <Inferred> inferred = null; if (definitions.TryGetValue(name, out defs)) { foreach (Definition definition in defs) { inferred = Engine.Union <Inferred>(inferred, definition.Resolve(engine, this)); } } return(inferred); }
private IList <FunctionInfo> InferMethods(SymbolId name, Scope scope) { IList <Inferred> inferred = Infer(new NameExpression(name), scope); IList <FunctionInfo> methods = null; if (inferred != null) { foreach (Inferred inf in inferred) { methods = Engine.Union(methods, inf.InferMethods(name)); } } return(methods); }
private IList <Inferred> InferCallExpression(CallExpression node, Scope scope) { IList <Inferred> targets = Infer(node.Target, scope); IList <Inferred> results = null; if (targets != null) { foreach (Inferred inf in targets) { if (inf.IsCallable) { results = Engine.Union(results, inf.InferResult(this)); } } } return(results); }
public IList <FunctionInfo> GetMethodsAt(int line, int column, string name) { Node node; Scope scope; Node context; IList <Inferred> methods = null; SymbolId nodeName = SymbolTable.Empty; if (Locate(typeof(CallExpression), line, column, out node, out scope, out context)) { if (context != null) { node = ((CallExpression)context).Target; } FieldExpression fe; NameExpression ne; if ((fe = node as FieldExpression) != null) { nodeName = fe.Name; methods = Engine.Infer(this, fe, scope); } else if ((ne = node as NameExpression) != null) { nodeName = ne.Name; methods = Engine.Infer(this, node, scope); } } if (methods != null) { IList <FunctionInfo> infos = null; foreach (Inferred inf in methods) { infos = Engine.Union(infos, inf.InferMethods(nodeName)); } return(infos); } return(null); }
public override IList <Inferred> Resolve(Engine engine, Scope scope) { Inferred import = engine.Import(name.Names[0]); IList <Inferred> previous = null; if (import != null) { previous = Engine.MakeList(import); for (int i = 1; i < name.Names.Count; i++) { IList <Inferred> next = null; foreach (Inferred inf in previous) { IList <Inferred> n2 = inf.InferName(name.Names[i], engine); next = Engine.Union(next, n2); } previous = next; } } return(previous); }