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); } } } }
public override void CheckBodySemantics(TigerScope scope, Report report) { TypeAccessNode.CheckSemantics(scope, report); //If type was not added to scope (if CheckSemantics failed) return if (!TypeAccessNode.IsOK || !IsOK) { IsOK = false; return; } scope.CompleteType(IdNode.Name, new ArrayType(IdNode.Name, TypeAccessNode.TigerType)); IsOK = true; }