public void NamedDataTypeExtractor_GetArgumentKindFromAttributes_OtherAttrs() { var ndte = new NamedDataTypeExtractor(platform, new DeclSpec[0], symbolTable); var kind = ndte.GetArgumentKindFromAttributes("arg", null); Assert.IsNull(kind); }
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, }); } } }
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, }); } } }
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; }
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); }
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); }
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); }
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); }
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); }
private void Run(DeclSpec[] declSpecs, Declarator decl) { var ndte = new NamedDataTypeExtractor(platform, declSpecs, symbolTable); this.nt = ndte.GetNameAndType(decl); }
public void NamedDataTypeExtractor_GetArgumentKindFromAttributes_OtherAttrs() { var ndte = new NamedDataTypeExtractor(new DeclSpec[0], parserState); var kind = ndte.GetArgumentKindFromAttributes(null); Assert.IsNull(kind); }
private void Run(DeclSpec[] declSpecs, Declarator decl) { var ndte = new NamedDataTypeExtractor(declSpecs, parserState); this.nt = ndte.GetNameAndType(decl); }
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); }