コード例 #1
0
ファイル: Member.cs プロジェクト: Dana-Ferguson/DotDart
        public Procedure(ComponentReader reader)
        {
            var s = reader.Position;

            reader.CheckTag(Tag);

            canonicalName   = new CanonicalNameReference(reader);
            fileUri         = new UriReference(reader);
            startFileOffset = new FileOffset(reader);

            fileOffset    = new FileOffset(reader);
            fileEndOffset = new FileOffset(reader);
            kind          = (ProcedureKind)reader.ReadByte();
            flags         = (Flag)reader.ReadByte();
            name          = new Name(reader);
            annotations   = reader.ReadList(r => r.ReadExpression());

            // #V12
            forwardingStubSuperTarget     = reader.ReadOption(r => new MemberReference(r));
            forwardingStubInterfaceTarget = reader.ReadOption(r => new MemberReference(r));

            // #V18?
            //forwardingStubSuperTarget = new MemberReference(reader);
            //forwardingStubInterfaceTarget = new MemberReference(reader);

            function = reader.ReadOption(r => new FunctionNode(r));
        }
コード例 #2
0
        public Class(ComponentReader reader)
        {
            reader.CheckTag(Tag);

            canonicalName = new CanonicalNameReference(reader);

            fileUri         = new UriReference(reader);
            startFileOffset = new FileOffset(reader);
            fileOffset      = new FileOffset(reader);
            fileEndOffset   = new FileOffset(reader);

            flags = (Flag)reader.ReadByte();

            name           = new StringReference(reader);
            annotations    = reader.ReadList(r => r.ReadExpression());
            typeParameters = reader.ReadList(r => new TypeParameter(r));

            superClass = reader.ReadOption(r => r.ReadDartType());

            mixedInType                    = reader.ReadOption(r => r.ReadDartType());
            implementedClasses             = reader.ReadList(r => r.ReadDartType());
            fields                         = reader.ReadList(r => new Field(r));
            constructors                   = reader.ReadList(r => new Constructor(r));
            procedures                     = reader.ReadList(r => new Procedure(r));
            redirectingFactoryConstructors = reader.ReadList(r => new RedirectingFactoryConstructor(r));
        }
コード例 #3
0
ファイル: Library.cs プロジェクト: Dana-Ferguson/DotDart
        // https://github.com/dart-lang/sdk/blob/master/pkg/kernel/lib/binary/ast_from_binary.dart#L760
        public Library(ComponentReader reader)
        {
            // Read the Offsets and Counts in a backward fashion
            var p = reader.Length - sizeof(uint);

            reader.Position = p;
            procedureCount  = reader.ReadUint32();

            p -= sizeof(uint) * ((int)procedureCount + 1);
            reader.Position  = p;
            procedureOffsets = reader.ReadUint32s((int)procedureCount + 1);

            p -= sizeof(uint);
            reader.Position = p;
            classCount      = reader.ReadUint32();

            p -= sizeof(uint) * ((int)classCount + 1);
            reader.Position = p;
            classOffsets    = reader.ReadUint32s((int)classCount + 1);

            reader.Position = 0;
            flags           = reader.ReadByte();
            canonicalName   = new CanonicalNameReference(reader);
            name            = new StringReference(reader);

            // todo: remove!
            Console.WriteLine($"{reader.GetString(name)} :: {classOffsets.Length} :: {classCount} || {procedureOffsets.Length} :: {procedureCount};");

            fileUri = new UriReference(reader);

            //   List<String> problemsAsJson; // Described in problems.md.

            annotations         = reader.ReadList(r => r.ReadExpression());
            libraryDependencies = reader.ReadList(r => new LibraryDependency(r));
            additionalExports   = reader.ReadList(r => new CanonicalNameReference(r));
            libraryParts        = reader.ReadList(r => new LibraryPart(r));
            typedefs            = reader.ReadList(r => new Typedef(r));

            // https://github.com/dart-lang/sdk/blob/master/pkg/kernel/lib/binary/ast_from_binary.dart#L831
            // classes = reader.ReadList(r => new Class(r));
            classes = new List <Class>((int)classCount);
            for (int i = 0; i < classCount; i++)
            {
                var start = classOffsets[i];
                var end   = classOffsets[i + 1];
                classes.Add(new Class(reader.GetWindow(start, end - start)));
            }

            reader.Position = (int)classOffsets.Last() - reader.WindowOffset;
            fields          = reader.ReadList(r => new Field(r));

            // procedures = reader.ReadList(r => new Procedure(r));
            procedures = new List <Procedure>((int)procedureCount);
            for (int i = 0; i < procedureCount; i++)
            {
                var start = procedureOffsets[i];
                var end   = procedureOffsets[i + 1];
                procedures.Add(new Procedure(reader.GetWindow(start, end - start)));
            }
        }
コード例 #4
0
ファイル: Member.cs プロジェクト: Dana-Ferguson/DotDart
 public Field(CanonicalNameReference canonicalName, UriReference fileUri, FileOffset fileOffset, FileOffset fileEndOffset,
              Flag flags, Name name, List <Expression> annotations, DartType type, Option <Expression> initializer)
 {
     this.canonicalName = canonicalName;
     this.fileUri       = fileUri;
     this.fileOffset    = fileOffset;
     this.fileEndOffset = fileEndOffset;
     this.flags         = flags;
     this.name          = name;
     this.annotations   = annotations;
     this.type          = type;
     this.initializer   = initializer;
 }
コード例 #5
0
ファイル: Member.cs プロジェクト: Dana-Ferguson/DotDart
        public Field(ComponentReader reader)
        {
            reader.CheckTag(Tag);

            canonicalName = new CanonicalNameReference(reader);
            fileUri       = new UriReference(reader);
            fileOffset    = new FileOffset(reader);
            fileEndOffset = new FileOffset(reader);
            flags         = (Flag)reader.ReadByte();
            name          = new Name(reader);
            annotations   = reader.ReadList(r => r.ReadExpression());
            type          = reader.ReadDartType();
            initializer   = reader.ReadOption(r => r.ReadExpression());
        }
コード例 #6
0
ファイル: Member.cs プロジェクト: Dana-Ferguson/DotDart
 public Constructor(CanonicalNameReference canonicalName, UriReference fileUri, FileOffset startFileOffset, FileOffset fileOffset, FileOffset fileEndOffset,
                    Flag flags, Name name, List <Expression> annotations, FunctionNode function, List <Initializer> initializers)
 {
     this.canonicalName   = canonicalName;
     this.fileUri         = fileUri;
     this.startFileOffset = startFileOffset;
     this.fileOffset      = fileOffset;
     this.fileEndOffset   = fileEndOffset;
     this.flags           = flags;
     this.name            = name;
     this.annotations     = annotations;
     this.function        = function;
     this.initializers    = initializers;
 }
コード例 #7
0
ファイル: Member.cs プロジェクト: Dana-Ferguson/DotDart
        public Constructor(ComponentReader reader)
        {
            reader.CheckTag(Tag);

            canonicalName   = new CanonicalNameReference(reader);
            fileUri         = new UriReference(reader);
            startFileOffset = new FileOffset(reader);
            fileOffset      = new FileOffset(reader);
            fileEndOffset   = new FileOffset(reader);
            flags           = (Flag)reader.ReadByte();
            name            = new Name(reader);
            annotations     = reader.ReadList(r => r.ReadExpression());
            function        = new FunctionNode(reader);
            initializers    = reader.ReadList(r => r.ReadInitializer());
        }
コード例 #8
0
ファイル: Member.cs プロジェクト: Dana-Ferguson/DotDart
 public Procedure(CanonicalNameReference canonicalName, UriReference fileUri, FileOffset startFileOffset, FileOffset fileOffset, FileOffset fileEndOffset,
                  ProcedureKind kind, Flag flags, Name name, List <Expression> annotations, Option <MemberReference> forwardingStubSuperTarget,
                  Option <MemberReference> forwardingStubInterfaceTarget, Option <FunctionNode> function)
 {
     this.canonicalName                 = canonicalName;
     this.fileUri                       = fileUri;
     this.startFileOffset               = startFileOffset;
     this.fileOffset                    = fileOffset;
     this.fileEndOffset                 = fileEndOffset;
     this.kind                          = kind;
     this.flags                         = flags;
     this.name                          = name;
     this.annotations                   = annotations;
     this.forwardingStubSuperTarget     = forwardingStubSuperTarget;
     this.forwardingStubInterfaceTarget = forwardingStubInterfaceTarget;
     this.function                      = function;
 }
コード例 #9
0
ファイル: Member.cs プロジェクト: Dana-Ferguson/DotDart
 public RedirectingFactoryConstructor(CanonicalNameReference canonicalName, UriReference fileUri, FileOffset fileOffset, FileOffset fileEndOffset,
                                      byte flags, Name name, List <Expression> annotations, MemberReference targetReference, List <DartType> typeArguments, List <TypeParameter> typeParameters,
                                      uint parameterCount, uint requiredParameterCount, List <VariableDeclaration> positionalParameters, List <VariableDeclaration> namedParameters)
 {
     this.canonicalName          = canonicalName;
     this.fileUri                = fileUri;
     this.fileOffset             = fileOffset;
     this.fileEndOffset          = fileEndOffset;
     this.flags                  = flags;
     this.name                   = name;
     this.annotations            = annotations;
     this.targetReference        = targetReference;
     this.typeArguments          = typeArguments;
     this.typeParameters         = typeParameters;
     this.parameterCount         = parameterCount;
     this.requiredParameterCount = requiredParameterCount;
     this.positionalParameters   = positionalParameters;
     this.namedParameters        = namedParameters;
 }
コード例 #10
0
ファイル: Member.cs プロジェクト: Dana-Ferguson/DotDart
        public RedirectingFactoryConstructor(ComponentReader reader)
        {
            reader.CheckTag(Tag);

            canonicalName = new CanonicalNameReference(reader);
            fileUri       = new UriReference(reader);
            fileOffset    = new FileOffset(reader);
            fileEndOffset = new FileOffset(reader);

            flags = reader.ReadByte();

            name                   = new Name(reader);
            annotations            = reader.ReadList(r => r.ReadExpression());
            targetReference        = new MemberReference(reader);
            typeArguments          = reader.ReadList(r => r.ReadDartType());
            typeParameters         = reader.ReadList(r => new TypeParameter(r));
            parameterCount         = reader.ReadUint();
            requiredParameterCount = reader.ReadUint();
            positionalParameters   = reader.ReadList(r => new VariableDeclaration(r));
            namedParameters        = reader.ReadList(r => new VariableDeclaration(r));
        }
コード例 #11
0
 // todo: this needs a builder class
 public Class(CanonicalNameReference canonicalName, UriReference fileUri, FileOffset startFileOffset, FileOffset fileOffset, FileOffset fileEndOffset,
              Flag flags, StringReference name, List <Expression> annotations, List <TypeParameter> typeParameters, Option <DartType> superClass,
              Option <DartType> mixedInType, List <DartType> implementedClasses, List <Field> fields, List <Constructor> constructors, List <Procedure> procedures,
              List <RedirectingFactoryConstructor> redirectingFactoryConstructors, uint[] procedureOffsets)
 {
     this.canonicalName                  = canonicalName;
     this.fileUri                        = fileUri;
     this.startFileOffset                = startFileOffset;
     this.fileOffset                     = fileOffset;
     this.fileEndOffset                  = fileEndOffset;
     this.flags                          = flags;
     this.name                           = name;
     this.annotations                    = annotations;
     this.typeParameters                 = typeParameters;
     this.superClass                     = superClass;
     this.mixedInType                    = mixedInType;
     this.implementedClasses             = implementedClasses;
     this.fields                         = fields;
     this.constructors                   = constructors;
     this.procedures                     = procedures;
     this.redirectingFactoryConstructors = redirectingFactoryConstructors;
     this.procedureOffsets               = procedureOffsets;
 }