private void ExpandType(TypeNameMember typeName) { // Circular references are wrong. AstNode typedefNode = typeName.GetTypedefNode(); if(typeName.IsExpanding) Error(typedefNode, "typedef with circular reference."); // Ignore expanded types. IChelaType type = typeName.GetActualType(); if(!type.IsIncompleteType()) return; // Set the expanding flag. typeName.IsExpanding = true; // Expand the dependencies first. IncompleteType incomplete = (IncompleteType)type; foreach(TypeNameMember dep in incomplete.Dependencies) ExpandType(dep); // Expand the type name itself. ExpandTypeNode((TypedefDefinition)typedefNode, true); // Unset the expanding flag. typeName.IsExpanding = false; }
public IncompleteType(List <object> vector) { // Read the type names. List <TypeNameMember> incompletes = new List <TypeNameMember> (); foreach (object dep in vector) { TypeNameMember typeName = dep as TypeNameMember; if (typeName != null) { incompletes.Add(typeName); } else { IncompleteType inc = (IncompleteType)dep; foreach (TypeNameMember incTypeName in inc.Dependencies) { incompletes.Add(incTypeName); } } } // Create the dependencies array. deps = incompletes.ToArray(); }
internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header) { // Create the temporal type name and register it. TypeNameMember typeName = new TypeNameMember(module); module.RegisterMember(typeName); // Read the name and flags. typeName.name = module.GetString(header.memberName); typeName.flags = (MemberFlags)header.memberFlags; // Skip the structure elements. reader.Skip(header.memberSize); }
public void SetTypeName(TypeNameMember typeName) { this.typeName = typeName; }
public override AstNode Visit(TypedefDefinition node) { // Prevent redefinition. ScopeMember old = currentContainer.FindMember(node.GetName()); if(old != null) Error(node, "trying to redefine a typedef."); // Create the type name. TypeNameMember typeName = new TypeNameMember(node.GetFlags(), node.GetName(), currentContainer); typeName.SetTypedefNode(node); node.SetTypeName(typeName); // Register the type name. if(currentContainer.IsNamespace()) { Namespace space = (Namespace)currentContainer; space.AddMember(typeName); } else if(currentContainer.IsStructure() || currentContainer.IsClass()) { Structure parent = (Structure)currentContainer; parent.AddTypeName(typeName); } else { Error(node, "unexpected place for a typedef."); } return node; }