public override AstNode Visit(MemberAccess node) { // This is the same as VariableReference implementation. // Get the node type. IChelaType variableType = node.GetNodeType(); // Ignore type references, namespaces and functions. if (variableType.IsMetaType() || variableType.IsNamespace() || variableType.IsFunctionGroup() || variableType.IsFunction()) { return(node); } // The type must be a reference. variableType = DeReferenceType(variableType); // Now, it must be a constant. if (!variableType.IsConstant()) { Error(node, "constant initialization can't reference no constant variables."); } // The node value, must be the constant variable. FieldVariable constantVar = (FieldVariable)node.GetNodeValue(); // Find the corresponding constant data. ConstantData depData; if (constants.TryGetValue(constantVar, out depData)) { currentConstant.AddDependency(depData); } return(node); }
public override AstNode Visit(UsingStatement node) { // Visit the using member. Expression member = node.GetMember(); member.Accept(this); // Cast the pseudo-scope. PseudoScope scope = (PseudoScope)node.GetScope(); // Get the member type. IChelaType memberType = member.GetNodeType(); if (memberType.IsMetaType()) { // Get the actual type. MetaType meta = (MetaType)memberType; memberType = meta.GetActualType(); // Only structure relatives. if (memberType.IsStructure() || memberType.IsClass() || memberType.IsInterface()) { scope.AddAlias(memberType.GetName(), (ScopeMember)memberType); } else { Error(node, "unexpected type."); } } else if (memberType.IsReference()) { // Only static members supported. ScopeMember theMember = (ScopeMember)member.GetNodeValue(); MemberFlags instanceFlags = MemberFlags.InstanceMask & theMember.GetFlags(); if (instanceFlags != MemberFlags.Static) { Error(node, "unexpected member type."); } // Store the member. scope.AddAlias(theMember.GetName(), theMember); } else if (memberType.IsNamespace()) { // Set the namespace chain. Namespace space = (Namespace)member.GetNodeValue(); scope.SetChainNamespace(space); } else { Error(node, "unsupported object to use."); } base.Visit(node); return(node); }