コード例 #1
0
 public void SolveTypes()
 {
     for (int i = 0; i < TypeDeclarationNodes.Length; i++)
     {
         if (Sets[i] == null)
         {
             continue;
         }
         var parentSet = DisjointSet.SetOf(Sets[i]);
         if (parentSet.IsInvalid)
         {
             Scope.RemoveType(Sets[i].Name);
             Report.AddError(SemanticErrors.CircularTypeDefinition(TypeDeclarationNodes[i], TypeDeclarationNodes[i].IdNode.Name));
         }
         else
         {
             DisjointSet.FirstArrayDependency(Sets[i]);
             if (Sets[i].TigerType is ArrayType)
             {
                 ((ArrayType)Sets[i].TigerType).ContentType = Sets[i].Parent.TigerType;
             }
             if (Sets[i].TigerType is SimpleType)
             {
                 ((SimpleType)Sets[i].TigerType).ActualType = Sets[i].Parent.TigerType;
             }
             if (!(TypeDeclarationNodes[i] is RecordTypeDeclarationNode))
             {
                 Scope.CompleteType(Sets[i].Name, Sets[i].TigerType);
             }
         }
     }
 }