コード例 #1
0
ファイル: TypeDeclarations.cs プロジェクト: Suchiman/vcc
        private static bool HasTypeCycle(ITypeReference type, IFieldDefinition /*?*/ offendingField, Stack <ITypeReference> seenTypes, LanguageSpecificCompilationHelper helper)
        {
            if (type.TypeCode != PrimitiveTypeCode.NotPrimitive ||
                !type.ResolvedType.IsStruct)
            {
                return(false);
            }

            lock (GlobalLock.LockingObject) {
                if (typesWithKnownLoops.ContainsKey(type))
                {
                    return(true);
                }
            }

            if (seenTypes.Contains(type))
            {
                lock (GlobalLock.LockingObject) {
                    if (!typesWithKnownLoops.ContainsKey(type))
                    {
                        typesWithKnownLoops.Add(type, true);
                        var location = IteratorHelper.First(helper.Compilation.SourceLocationProvider.GetPrimarySourceLocationsFor(type.Locations));
                        helper.ReportError(
                            new VccErrorMessage(location,
                                                Error.ValueTypeLayoutCycle, offendingField.Name.Value, helper.GetTypeName(type.ResolvedType)));
                    }
                }
                return(true);
            }

            seenTypes.Push(type);
            bool hasCycle = false;

            foreach (var field in IteratorHelper.GetFilterEnumerable <ITypeDefinitionMember, IFieldDefinition>(type.ResolvedType.Members))
            {
                if (!field.IsStatic)
                {
                    hasCycle |= VccStructuredTypeDeclaration.HasTypeCycle(field.Type, field, seenTypes, helper);
                }
            }

            seenTypes.Pop();
            return(hasCycle);
        }
コード例 #2
0
ファイル: TypeDeclarations.cs プロジェクト: edgar-pek/VCDryad
        private static bool HasTypeCycle(ITypeReference type, IFieldDefinition/*?*/ offendingField, Stack<ITypeReference> seenTypes, LanguageSpecificCompilationHelper helper)
        {
            if (type.TypeCode != PrimitiveTypeCode.NotPrimitive ||
              !type.ResolvedType.IsStruct) return false;

              lock (GlobalLock.LockingObject) {
            if (typesWithKnownLoops.ContainsKey(type)) return true;
              }

              if (seenTypes.Contains(type)) {
            lock (GlobalLock.LockingObject) {
              if (!typesWithKnownLoops.ContainsKey(type)) {
            typesWithKnownLoops.Add(type, true);
            var location = IteratorHelper.First(helper.Compilation.SourceLocationProvider.GetPrimarySourceLocationsFor(type.Locations));
            helper.ReportError(
              new VccErrorMessage(location,
                Error.ValueTypeLayoutCycle, offendingField.Name.Value, helper.GetTypeName(type.ResolvedType)));
              }
            }
            return true;
              }

              seenTypes.Push(type);
              bool hasCycle = false;
              foreach (var field in IteratorHelper.GetFilterEnumerable<ITypeDefinitionMember, IFieldDefinition>(type.ResolvedType.Members)) {
            if (!field.IsStatic) {
              hasCycle |= VccStructuredTypeDeclaration.HasTypeCycle(field.Type, field, seenTypes, helper);
            }
              }

              seenTypes.Pop();
              return hasCycle;
        }
コード例 #3
0
ファイル: TypeDeclarations.cs プロジェクト: Suchiman/vcc
        internal static bool HasFieldOfUnspecifiedType(ITypeReference type, IEnumerable <ITypeDefinitionMember> members, LanguageSpecificCompilationHelper helper)
        {
            bool errorFound = false;

            foreach (var member in members)
            {
                var field = member as IFieldDefinition;
                if (field != null && field.Type == helper.Compilation.PlatformType.SystemVoid.ResolvedType)
                {
                    var fieldDecl = ((Cci.Ast.FieldDefinition)field).Declaration as FieldDefinition;
                    var location  = IteratorHelper.First(helper.Compilation.SourceLocationProvider.GetPrimarySourceLocationsFor(type.Locations));
                    helper.ReportError(
                        new VccErrorMessage(location,
                                            Error.IllegalUseOfUndefinedType,
                                            field.Name.Value,
                                            fieldDecl != null ? fieldDecl.Type.SourceLocation.Source : helper.GetTypeName(field.Type.ResolvedType)));
                    errorFound = true;
                }
            }

            return(errorFound);
        }
コード例 #4
0
ファイル: TypeDeclarations.cs プロジェクト: edgar-pek/VCDryad
        internal static bool HasFieldOfUnspecifiedType(ITypeReference type,  IEnumerable<ITypeDefinitionMember> members, LanguageSpecificCompilationHelper helper)
        {
            bool errorFound = false;
              foreach (var member in members)
              {
            var field = member as IFieldDefinition;
            if (field != null && field.Type == helper.Compilation.PlatformType.SystemVoid.ResolvedType)
            {
              var fieldDecl = ((Cci.Ast.FieldDefinition) field).Declaration as FieldDefinition;
              var location = IteratorHelper.First(helper.Compilation.SourceLocationProvider.GetPrimarySourceLocationsFor(type.Locations));
            helper.ReportError(
              new VccErrorMessage(location,
                                  Error.IllegalUseOfUndefinedType,
                                  field.Name.Value,
                                  fieldDecl != null ? fieldDecl.Type.SourceLocation.Source : helper.GetTypeName(field.Type.ResolvedType)));
              errorFound = true;
            }
              }

              return errorFound;
        }