diff options
| author | Ted Kremenek <kremenek@apple.com> | 2007-11-02 18:05:11 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2007-11-02 18:05:11 +0000 |
| commit | dda9a56975dac9f5155c0c1dbada0316250724fc (patch) | |
| tree | e32a8f5dcfd500c1d3c5f26ceded7e19afe018e4 /clang/AST/DeclSerialization.cpp | |
| parent | 3ae79b3d13b0c075b395dd0d1dd974276d0ebc54 (diff) | |
| download | bcm5719-llvm-dda9a56975dac9f5155c0c1dbada0316250724fc.tar.gz bcm5719-llvm-dda9a56975dac9f5155c0c1dbada0316250724fc.zip | |
Added most of the boilerplate code for Decl serialization. Still a few
key functions to implement.
llvm-svn: 43648
Diffstat (limited to 'clang/AST/DeclSerialization.cpp')
| -rw-r--r-- | clang/AST/DeclSerialization.cpp | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/clang/AST/DeclSerialization.cpp b/clang/AST/DeclSerialization.cpp index 3a326f006b4..c07edb4a589 100644 --- a/clang/AST/DeclSerialization.cpp +++ b/clang/AST/DeclSerialization.cpp @@ -26,3 +26,120 @@ Decl* Decl::Materialize(llvm::Deserializer& D) { assert ("FIXME: not implemented."); return NULL; } + +void NamedDecl::InternalEmit(llvm::Serializer& S) const { + S.EmitPtr(Identifier); +} + +void NamedDecl::InternalRead(llvm::Deserializer& D) { + D.ReadPtr(Identifier); +} + +void ScopedDecl::InternalEmit(llvm::Serializer& S) const { + NamedDecl::InternalEmit(S); + S.EmitPtr(Next); + S.EmitOwnedPtr<Decl>(NextDeclarator); +} + +void ScopedDecl::InternalRead(llvm::Deserializer& D) { + NamedDecl::InternalRead(D); + D.ReadPtr(Next); + NextDeclarator = cast<ScopedDecl>(D.ReadOwnedPtr<Decl>()); +} + +void ValueDecl::InternalEmit(llvm::Serializer& S) const { + S.Emit(DeclType); + ScopedDecl::InternalEmit(S); +} + +void ValueDecl::InternalRead(llvm::Deserializer& D) { + D.Read(DeclType); + ScopedDecl::InternalRead(D); +} + +void VarDecl::InternalEmit(llvm::Serializer& S) const { + S.EmitInt(SClass); + S.EmitInt(objcDeclQualifier); + VarDecl::InternalEmit(S); + S.EmitOwnedPtr(Init); +} + +void VarDecl::InternalRead(llvm::Deserializer& D) { + SClass = D.ReadInt(); + objcDeclQualifier = static_cast<ObjcDeclQualifier>(D.ReadInt()); + VarDecl::InternalRead(D); + D.ReadOwnedPtr(Init); +} + + +void BlockVarDecl::Emit(llvm::Serializer& S) const { + S.Emit(getLocation()); + VarDecl::InternalEmit(S); +} + +BlockVarDecl* BlockVarDecl::Materialize(llvm::Deserializer& D) { + SourceLocation L = SourceLocation::ReadVal(D); + BlockVarDecl* decl = new BlockVarDecl(L,NULL,QualType(),None,NULL); + decl->VarDecl::InternalRead(D); + return decl; +} + +void FileVarDecl::Emit(llvm::Serializer& S) const { + S.Emit(getLocation()); + VarDecl::InternalEmit(S); +} + +FileVarDecl* FileVarDecl::Materialize(llvm::Deserializer& D) { + SourceLocation L = SourceLocation::ReadVal(D); + FileVarDecl* decl = new FileVarDecl(L,NULL,QualType(),None,NULL); + decl->VarDecl::InternalRead(D); + return decl; +} + +void ParmVarDecl::Emit(llvm::Serializer& S) const { + S.Emit(getLocation()); + VarDecl::InternalEmit(S); +} + +ParmVarDecl* ParmVarDecl::Materialize(llvm::Deserializer& D) { + SourceLocation L = SourceLocation::ReadVal(D); + ParmVarDecl* decl = new ParmVarDecl(L,NULL,QualType(),None,NULL); + decl->VarDecl::InternalRead(D); + return decl; +} + +void FunctionDecl::Emit(llvm::Serializer& S) const { + S.Emit(getLocation()); + S.EmitInt(SClass); + S.EmitBool(IsInline); + + ValueDecl::InternalEmit(S); + + unsigned NumParams = getNumParams(); + S.EmitInt(NumParams); + + for (unsigned i = 0 ; i < NumParams; ++i) + S.EmitOwnedPtr(ParamInfo[i]); + + S.EmitOwnedPtr(Body); +} + +FunctionDecl* FunctionDecl::Materialize(llvm::Deserializer& D) { + SourceLocation L = SourceLocation::ReadVal(D); + StorageClass SClass = static_cast<StorageClass>(D.ReadInt()); + bool IsInline = D.ReadBool(); + + FunctionDecl* decl = new FunctionDecl(L,NULL,QualType(),SClass,IsInline); + + decl->ValueDecl::InternalRead(D); + + unsigned NumParams = D.ReadInt(); + decl->ParamInfo = NumParams ? new ParmVarDecl*[NumParams] : NULL; + + for (unsigned i = 0 ; i < NumParams; ++i) + D.ReadOwnedPtr(decl->ParamInfo[i]); + + D.ReadOwnedPtr(decl->Body); + + return decl; +} |

