public override ExpressionNode GetSymbol(string name, ContextNode scope, SequencePoint point) { var field = GetField(name); if (field != null) { return(new FieldNode(null, field, scope, point)); } var methods = GetMethods(name); if (scope.IsStaticContext()) { methods = methods.Where(m => m.IsStatic()); } if (methods.Count() > 0) { return(AmbiguousMethodNode.Create(methods, scope, null, point)); } var type = GetContainedType(name); if (type != null) { return(TypeNode.Create(type, scope, point)); } var namespaze = GetImportedNamespace(name, point); if (namespaze != null) { return(new NamespaceNode(namespaze, point)); } type = GetImportedType(name, point); if (type != null) { return(TypeNode.Create(type, scope, point)); } if (Parent != null) { return(Parent.GetSymbol(name, scope, point)); } namespaze = Parser.ProjectParser.FindNamespace(name); if (namespaze != null) { return(new NamespaceNode(namespaze, point)); } type = Parser.ProjectParser.FindType(name); if (type != null) { return(TypeNode.Create(type, scope, point)); } return(null); }
public static ThisNode Create(ContextNode scope, SequencePoint point) { if (scope.IsStaticContext()) { ErrorCode.MissingInstance.ReportAndThrow(point, "Cannot use 'this' inside a static context"); return(null);//unreachable } else { return(new ThisNode(scope.GetClass().TypeReference, point)); } }
protected static ExpressionNode GetInstance(MemberReference member, ExpressionNode specifiedInstance, ContextNode context, SequencePoint point) { if (specifiedInstance != null) { return(specifiedInstance); } if (member.IsStatic()) { return(null); } if (!context.IsStaticContext() && context.GetClass().TypeReference.IsAssignableTo(member.DeclaringType)) { return(ThisNode.Create(context, null)); } ErrorCode.MissingInstance.ReportAndThrow(point, "Cannot access non-static member {0} from a static context", member.FullName); return(null);//unreachable }