コード例 #1
0
        public void NamedDataTypeExtractor_GetArgumentKindFromAttributes_OtherAttrs()
        {
            var ndte = new NamedDataTypeExtractor(platform, new DeclSpec[0], symbolTable);
            var kind = ndte.GetArgumentKindFromAttributes("arg", null);

            Assert.IsNull(kind);
        }
コード例 #2
0
ファイル: AmigaHeaderLoader.cs プロジェクト: relaxar/reko
 public void ProcessDeclaration(Decl declaration, IPlatform platform, TypeLibraryDeserializer tldser, SymbolTable symbolTable)
 {
     var types = symbolTable.AddDeclaration(declaration);
     var type = types[0];
     int? vectorOffset = GetVectorOffset(declaration);
     if (vectorOffset.HasValue)
     {
         var ntde = new NamedDataTypeExtractor(platform, declaration.decl_specs, symbolTable);
         foreach (var declarator in declaration.init_declarator_list)
         {
             var nt = ntde.GetNameAndType(declarator.Declarator);
             var ssig = (SerializedSignature)nt.DataType;
             if (ssig.ReturnValue != null)
             {
                 ssig.ReturnValue.Kind = ntde.GetArgumentKindFromAttributes(
                     "returns", declaration.attribute_list);
             }
             var sser = platform.CreateProcedureSerializer(tldser, platform.DefaultCallingConvention);
             var sig = sser.Deserialize(ssig, platform.Architecture.CreateFrame());
             SystemServices.Add(
                 vectorOffset.Value,
                 new SystemService
                 {
                     Name = nt.Name,
                     SyscallInfo = new SyscallInfo
                     {
                         Vector = vectorOffset.Value,
                     },
                     Signature = sig,
                 });
         }
     }
 }
コード例 #3
0
        public void ProcessDeclaration(Decl declaration, IPlatform platform, TypeLibraryDeserializer tldser, SymbolTable symbolTable)
        {
            var types        = symbolTable.AddDeclaration(declaration);
            var type         = types[0];
            int?vectorOffset = GetVectorOffset(declaration);

            if (vectorOffset.HasValue)
            {
                var ntde = new NamedDataTypeExtractor(platform, declaration.decl_specs, symbolTable, 4);
                foreach (var declarator in declaration.init_declarator_list)
                {
                    var nt   = ntde.GetNameAndType(declarator.Declarator);
                    var ssig = (SerializedSignature?)nt.DataType;
                    if (ssig != null && ssig.ReturnValue != null)
                    {
                        ssig.ReturnValue.Kind = ntde.GetArgumentKindFromAttributes(
                            "returns", declaration.attribute_list);
                    }
                    var sser = new ProcedureSerializer(platform, tldser, platform.DefaultCallingConvention);
                    var sig  = sser.Deserialize(ssig, platform.Architecture.CreateFrame());
                    SystemServices.Add(
                        vectorOffset.Value,
                        new SystemService
                    {
                        Name        = nt.Name,
                        SyscallInfo = new SyscallInfo
                        {
                            Vector = vectorOffset.Value,
                        },
                        Signature = sig,
                    });
                }
            }
        }
コード例 #4
0
ファイル: SymbolTable.cs プロジェクト: gitter-badger/reko
        public List<SerializedType> AddDeclaration(Decl decl)
        {
            var types = new List<SerializedType>();
            var fndec = decl as FunctionDecl;
            if (fndec != null)
            {
                return types; 
            }

            IEnumerable<DeclSpec> declspecs = decl.decl_specs;
            var isTypedef = false;
            var scspec = decl.decl_specs[0] as StorageClassSpec;
            if (scspec != null && scspec.Type == CTokenType.Typedef)
            {
                declspecs = decl.decl_specs.Skip(1);
                isTypedef = true;
            }

            var ntde = new NamedDataTypeExtractor(platform, declspecs, this);
            foreach (var declarator in decl.init_declarator_list)
            {
                var nt = ntde.GetNameAndType(declarator.Declarator);
                var serType = nt.DataType;

                var sSig = nt.DataType as SerializedSignature;
                if (sSig != null)
                {
                    if (sSig.ReturnValue != null)
                    {
                        sSig.ReturnValue.Kind = ntde.GetArgumentKindFromAttributes(decl.attribute_list);
                    }
                    Procedures.Add(new Procedure_v1
                    {
                        Name = nt.Name,
                        Signature = sSig,
                    });
                    types.Add(sSig);
                }
                if (isTypedef)
                {
                    //$REVIEW: should make sure that if the typedef already exists, 
                    // then the types match but a real compiler would have validated that.
                    var typedef = new SerializedTypedef
                    {
                        Name = nt.Name,
                        DataType = serType
                    };
                    Types.Add(typedef);
                    //$REVIEW: do we really need to check for consistence?
                    NamedTypes[typedef.Name] = serType;
                    types.Add(serType);
                }
            }
            return types;
        }
コード例 #5
0
 public void NamedDataTypeExtractor_GetArgumentKindFromAttributes_null()
 {
     var ndte = new NamedDataTypeExtractor(new DeclSpec[0], parserState);
     var kind = ndte.GetArgumentKindFromAttributes(new List<CAttribute>
     {
         new CAttribute {
              Name = new QualifiedName { Components = new[] { "foo", "bar"} }
         }
     });
     Assert.IsNull(kind);
 }
コード例 #6
0
        public void NamedDataTypeExtractor_GetArgumentKindFromAttributes_null()
        {
            var ndte = new NamedDataTypeExtractor(platform, new DeclSpec[0], symbolTable);
            var kind = ndte.GetArgumentKindFromAttributes(new List <CAttribute>
            {
                new CAttribute {
                    Name = new QualifiedName {
                        Components = new[] { "foo", "bar" }
                    }
                }
            });

            Assert.IsNull(kind);
        }
コード例 #7
0
 public void NamedDataTypeExtractor_GetArgumentKindFromAttributes_reko_reg()
 {
     var ndte = new NamedDataTypeExtractor(new DeclSpec[0], parserState);
     var kind = ndte.GetArgumentKindFromAttributes(new List<CAttribute>
     {
         new CAttribute {
              Name = new QualifiedName("reko", "reg"),
              Tokens = new List<CToken> {
                  new CToken(CTokenType.StringLiteral, "D0")
              }
         }
     });
     Assert.IsNotNull(kind);
     var sReg = (Register_v1)kind;
     Assert.AreEqual("D0", sReg.Name);
 }
コード例 #8
0
        public void NamedDataTypeExtractor_GetArgumentKindFromAttributes_reko_x87_fpu()
        {
            var ndte = new NamedDataTypeExtractor(platform, new DeclSpec[0], symbolTable);
            var kind = ndte.GetArgumentKindFromAttributes(
                "arg",
                new List <CAttribute>
            {
                new CAttribute {
                    Name   = new QualifiedName("reko", "arg"),
                    Tokens = new List <CToken> {
                        new CToken(CTokenType.Id, "fpu")
                    }
                }
            });

            Assert.IsNotNull(kind);
            Assert.IsInstanceOf <FpuStackVariable_v1>(kind);
        }
コード例 #9
0
        public void NamedDataTypeExtractor_GetArgumentKindFromAttributes_reko_reg()
        {
            var ndte = new NamedDataTypeExtractor(platform, new DeclSpec[0], symbolTable);
            var kind = ndte.GetArgumentKindFromAttributes(new List <CAttribute>
            {
                new CAttribute {
                    Name   = new QualifiedName("reko", "reg"),
                    Tokens = new List <CToken> {
                        new CToken(CTokenType.StringLiteral, "D0")
                    }
                }
            });

            Assert.IsNotNull(kind);
            var sReg = (Register_v1)kind;

            Assert.AreEqual("D0", sReg.Name);
        }
コード例 #10
0
        private void Run(DeclSpec[] declSpecs, Declarator decl)
        {
            var ndte = new NamedDataTypeExtractor(platform, declSpecs, symbolTable);

            this.nt = ndte.GetNameAndType(decl);
        }
コード例 #11
0
 public void NamedDataTypeExtractor_GetArgumentKindFromAttributes_OtherAttrs()
 {
     var ndte = new NamedDataTypeExtractor(new DeclSpec[0], parserState);
     var kind = ndte.GetArgumentKindFromAttributes(null);
     Assert.IsNull(kind);
 }
コード例 #12
0
 private void Run(DeclSpec[] declSpecs, Declarator decl)
 {
     var ndte = new NamedDataTypeExtractor(declSpecs, parserState);
     this.nt = ndte.GetNameAndType(decl);
 }
コード例 #13
0
        private void Run(DeclSpec[] declSpecs, Declarator decl)
        {
            var ndte = new NamedDataTypeExtractor(declSpecs, parserState);

            this.nt = ndte.GetNameAndType(decl);
        }
コード例 #14
0
 private void Run(DeclSpec[] declSpecs, Declarator decl)
 {
     var ndte = new NamedDataTypeExtractor(platform, declSpecs, symbolTable);
     this.nt = ndte.GetNameAndType(decl);
 }
コード例 #15
0
 public void NamedDataTypeExtractor_GetArgumentKindFromAttributes_reko_x87_fpu()
 {
     var ndte = new NamedDataTypeExtractor(platform, new DeclSpec[0], symbolTable);
     var kind = ndte.GetArgumentKindFromAttributes(
         "arg",
         new List<CAttribute>
         {
             new CAttribute {
                  Name = new QualifiedName("reko", "arg"),
                  Tokens = new List<CToken> {
                      new CToken(CTokenType.Id, "fpu")
                  }
             }
         });
     Assert.IsNotNull(kind);
     Assert.IsInstanceOf<FpuStackVariable_v1>(kind);
 }
コード例 #16
0
 public void NamedDataTypeExtractor_GetArgumentKindFromAttributes_OtherAttrs()
 {
     var ndte = new NamedDataTypeExtractor(platform, new DeclSpec[0], symbolTable);
     var kind = ndte.GetArgumentKindFromAttributes("arg", null);
     Assert.IsNull(kind);
 }