Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        // 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)));
            }
        }
Esempio n. 3
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));
        }
Esempio n. 4
0
 public Field(CanonicalNameReference canonicalName, Flag flags, Name name, List <Expression> annotations, DartType type, Option <Expression> initializer)
 {
     this.canonicalName = canonicalName;
     this.flags         = flags;
     this.name          = name;
     this.annotations   = annotations;
     this.type          = type;
     this.initializer   = initializer;
 }
Esempio n. 5
0
 public Constructor(CanonicalNameReference canonicalName, Flag flags, Name name,
                    List <Expression> annotations, FunctionNode function, List <Initializer> initializers)
 {
     this.canonicalName = canonicalName;
     this.flags         = flags;
     this.name          = name;
     this.annotations   = annotations;
     this.function      = function;
     this.initializers  = initializers;
 }
Esempio n. 6
0
 public FunctionType(List <TypeParameter> typeParameters, uint requiredParameterCount, uint totalParameterCount,
                     List <DartType> positionalParameters, List <NamedDartType> namedParameters, CanonicalNameReference typedefReference, DartType returnType)
 {
     this.typeParameters         = typeParameters;
     this.requiredParameterCount = requiredParameterCount;
     this.totalParameterCount    = totalParameterCount;
     this.positionalParameters   = positionalParameters;
     this.namedParameters        = namedParameters;
     this.typedefReference       = typedefReference;
     this.returnType             = returnType;
 }
Esempio n. 7
0
 public Procedure(CanonicalNameReference canonicalName, ProcedureKind kind, Flag flags, Name name, List <Expression> annotations,
                  Option <MemberReference> forwardingStubSuperTarget, Option <MemberReference> forwardingStubInterfaceTarget, Option <FunctionNode> function)
 {
     this.canonicalName                 = canonicalName;
     this.kind                          = kind;
     this.flags                         = flags;
     this.name                          = name;
     this.annotations                   = annotations;
     this.forwardingStubSuperTarget     = forwardingStubSuperTarget;
     this.forwardingStubInterfaceTarget = forwardingStubInterfaceTarget;
     this.function                      = function;
 }
Esempio n. 8
0
 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;
 }
Esempio n. 9
0
 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;
 }
Esempio n. 10
0
        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());
        }
Esempio n. 11
0
        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());
        }
Esempio n. 12
0
        public FunctionType(ComponentReader reader)
        {
            typeParameters         = reader.ReadList(r => new TypeParameter(r));
            requiredParameterCount = reader.ReadUint();
            totalParameterCount    = reader.ReadUint();
            positionalParameters   = reader.ReadList(r => r.ReadDartType());
            namedParameters        = reader.ReadList(r => new NamedDartType(r));

            // #v12:   CanonicalNameReference typedefReference;
            // #v12+:  Option<TypedefType> typedef;
            typedefReference = new CanonicalNameReference(reader);
            //typedef = reader.ReadOption(r => new TypedefType(r));

            returnType = reader.ReadDartType();
        }
Esempio n. 13
0
 public RedirectingFactoryConstructor(CanonicalNameReference canonicalName,
                                      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.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;
 }
Esempio n. 14
0
        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));
        }
Esempio n. 15
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;
 }
Esempio n. 16
0
 public TypedefReference(ComponentReader reader)
 {
     canonicalName = new CanonicalNameReference(reader);
 }
Esempio n. 17
0
 public ProcedureReference(ComponentReader reader)
 {
     canonicalName = new CanonicalNameReference(reader);
 }
Esempio n. 18
0
 public ConstructorReference(ComponentReader reader)
 {
     canonicalName = new CanonicalNameReference(reader);
 }
Esempio n. 19
0
 public FieldReference(ComponentReader reader)
 {
     canonicalName = new CanonicalNameReference(reader);
 }
Esempio n. 20
0
 public MemberReference(string value)
 {
     this.canonicalName = new CanonicalNameReference(value);
 }
Esempio n. 21
0
 public MemberReference(CanonicalNameReference canonicalName)
 {
     this.canonicalName = canonicalName;
 }
Esempio n. 22
0
 // todo, annotate with allowNull
 public MemberReference(ComponentReader reader)
 {
     canonicalName = new CanonicalNameReference(reader);
 }
Esempio n. 23
0
 public LibraryReference(ComponentReader reader)
 {
     canonicalName = new CanonicalNameReference(reader);
 }
Esempio n. 24
0
 public CanonicalName(ComponentReader reader)
 {
     parent = new CanonicalNameReference(reader);
     name   = new StringReference(reader);
 }