sun::serialization::ASTSerializer

sun::serialization::ASTSerializer

class · Source (opens in a new tab)

class sun::serialization::ASTSerializer

Serialize AST nodes to protobuf format.

Public Functions

ASTSerializer

public · function · Source (opens in a new tab)

sun::serialization::ASTSerializer::ASTSerializer(SerializerConfig config={})

Creates a syntax-tree encoder using the supplied serialization settings.

Related: SerializerConfig

serialize

public · function · Source (opens in a new tab)

pbc::ASTNode sun::serialization::ASTSerializer::serialize(const ExprAST &expr) const

Serialize any expression node.

Related: ExprAST

serializeConstantValue

public · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeConstantValue(const sun::semantic_analysis::constants::ConstantValue &value, pbc::ConstantValue *proto) const

Writes a value the compiler computed for a global.

Its type is not written: the reader takes it from the global's own type.

Related: sun::semantic_analysis::constants::ConstantValue

serializeProgram

public · function · Source (opens in a new tab)

pbc::Program sun::serialization::ASTSerializer::serializeProgram(const BlockExprAST &root) const

Serialize a complete program (root block).

Related: BlockExprAST

serializeProgramToString

public · function · Source (opens in a new tab)

std::string sun::serialization::ASTSerializer::serializeProgramToString(const BlockExprAST &root) const

Encodes a program syntax tree as a protobuf byte string.

Related: BlockExprAST

serializePrototype

public · function · Source (opens in a new tab)

pbc::Prototype sun::serialization::ASTSerializer::serializePrototype(const sun::ast::PrototypeAST &proto) const

Serialize a prototype (non-ExprAST node).

Related: sun::ast::PrototypeAST

serializeToString

public · function · Source (opens in a new tab)

std::string sun::serialization::ASTSerializer::serializeToString(const ExprAST &expr) const

Serialize to bytes (convenience).

Related: ExprAST

Private Functions

serializeArray

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeArray(const sun::ast::ArrayLiteralAST &expr, pbc::ASTNode *node) const

Encodes a array literal and its child data in the protobuf syntax representation.

Related: sun::ast::ArrayLiteralAST

serializeArrayIndex

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeArrayIndex(const sun::ast::ArrayIndexAST &expr, pbc::ASTNode *node) const

Encodes a array index and its child data in the protobuf syntax representation.

Related: sun::ast::ArrayIndexAST

serializeBinary

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeBinary(const sun::ast::BinaryExprAST &expr, pbc::ASTNode *node) const

Encodes a binary operation and its child data in the protobuf syntax representation.

Related: sun::ast::BinaryExprAST

serializeBlock

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeBlock(const BlockExprAST &expr, pbc::ASTNode *node) const

Encodes a lexical block and its child data in the protobuf syntax representation.

Related: BlockExprAST

serializeBlockInto

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeBlockInto(const BlockExprAST &block, pbc::BlockExpr *proto) const

Statements and span of a block that is stored without a node wrapper (function bodies, module bodies, try and catch blocks).

Related: BlockExprAST

serializeBool

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeBool(const sun::ast::BoolLiteralAST &expr, pbc::ASTNode *node) const

Encodes a boolean literal and its child data in the protobuf syntax representation.

Related: sun::ast::BoolLiteralAST

serializeCall

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeCall(const sun::ast::CallExprAST &expr, pbc::ASTNode *node) const

Encodes a function call and its child data in the protobuf syntax representation.

Related: sun::ast::CallExprAST

serializeCharLiteral

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeCharLiteral(const sun::ast::CharLiteralAST &expr, pbc::ASTNode *node) const

Encodes a character literal and its child data in the protobuf syntax representation.

Related: sun::ast::CharLiteralAST

serializeClassDef

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeClassDef(const sun::ast::ClassDefinitionAST &expr, pbc::ASTNode *node) const

Encodes a class declaration and its child data in the protobuf syntax representation.

Related: sun::ast::ClassDefinitionAST

serializeCompoundAssignment

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeCompoundAssignment(const sun::ast::CompoundAssignmentAST &expr, pbc::ASTNode *node) const

Encodes a compound assignment and its child data in the protobuf syntax representation.

Related: sun::ast::CompoundAssignmentAST

serializeDeclareType

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeDeclareType(const sun::ast::DeclareTypeAST &expr, pbc::ASTNode *node) const

Encodes a forward type declaration and its child data in the protobuf syntax representation.

Related: sun::ast::DeclareTypeAST

serializeEnumDef

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeEnumDef(const sun::ast::EnumDefinitionAST &expr, pbc::ASTNode *node) const

Encodes a enum declaration and its child data in the protobuf syntax representation.

Related: sun::ast::EnumDefinitionAST

serializeExprBase

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeExprBase(const ExprAST &expr, pbc::ASTNode *node) const

Set common ExprAST fields on the proto message.

Related: ExprAST, ExprAST

serializeFieldInto

private · function · Source (opens in a new tab)

template <typename FieldDecl, typename FieldProto>
void sun::serialization::ASTSerializer::serializeFieldInto(const FieldDecl &field, FieldProto *proto) const

Class and interface fields are declared alike, so they store alike.

serializeFor

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeFor(const sun::ast::ForExprAST &expr, pbc::ASTNode *node) const

Encodes a for loop and its child data in the protobuf syntax representation.

Related: sun::ast::ForExprAST

serializeForIn

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeForIn(const sun::ast::ForInExprAST &expr, pbc::ASTNode *node) const

Encodes a iteration loop and its child data in the protobuf syntax representation.

Related: sun::ast::ForInExprAST

serializeFunction

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeFunction(const sun::ast::FunctionAST &expr, pbc::ASTNode *node) const

Encodes a function definition and its child data in the protobuf syntax representation.

Related: sun::ast::FunctionAST

serializeGenericCall

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeGenericCall(const sun::ast::GenericCallAST &expr, pbc::ASTNode *node) const

Encodes a generic function call and its child data in the protobuf syntax representation.

Related: sun::ast::GenericCallAST

serializeIdentity

private · function · Source (opens in a new tab)

pbc::DeclarationIdentity sun::serialization::ASTSerializer::serializeIdentity(const sun::semantic_analysis::DeclarationIdentity &identity) const

Export declaration and binder keys only at the artifact boundary.

Related: sun::semantic_analysis::DeclarationIdentity

serializeIf

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeIf(const sun::ast::IfExprAST &expr, pbc::ASTNode *node) const

Encodes a conditional expression and its child data in the protobuf syntax representation.

Related: sun::ast::IfExprAST

serializeIndex

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeIndex(const sun::ast::IndexAST &expr, pbc::ASTNode *node) const

Encodes a index expression and its child data in the protobuf syntax representation.

Related: sun::ast::IndexAST

serializeIndexedAssignment

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeIndexedAssignment(const sun::ast::IndexedAssignmentAST &expr, pbc::ASTNode *node) const

Encodes a indexed assignment and its child data in the protobuf syntax representation.

Related: sun::ast::IndexedAssignmentAST

serializeInterfaceDef

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeInterfaceDef(const sun::ast::InterfaceDefinitionAST &expr, pbc::ASTNode *node) const

Encodes a interface declaration and its child data in the protobuf syntax representation.

Related: sun::ast::InterfaceDefinitionAST

serializeInterpolatedString

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeInterpolatedString(const sun::ast::InterpolatedStringAST &expr, pbc::ASTNode *node) const

Encodes a interpolated string and its child data in the protobuf syntax representation.

Related: sun::ast::InterpolatedStringAST

serializeLambda

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeLambda(const sun::ast::LambdaAST &expr, pbc::ASTNode *node) const

Encodes a lambda expression and its child data in the protobuf syntax representation.

Related: sun::ast::LambdaAST

serializeManifest

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeManifest(const sun::ast::ManifestAST &expr, pbc::ASTNode *node) const

Encodes a dependency manifest and its child data in the protobuf syntax representation.

Related: sun::ast::ManifestAST

serializeMatch

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeMatch(const sun::ast::MatchExprAST &expr, pbc::ASTNode *node) const

Encodes a pattern match and its child data in the protobuf syntax representation.

Related: sun::ast::MatchExprAST

serializeMemberAccess

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeMemberAccess(const sun::ast::MemberAccessAST &expr, pbc::ASTNode *node) const

Encodes a member access and its child data in the protobuf syntax representation.

Related: sun::ast::MemberAccessAST

serializeMemberAssignment

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeMemberAssignment(const sun::ast::MemberAssignmentAST &expr, pbc::ASTNode *node) const

Encodes a member assignment and its child data in the protobuf syntax representation.

Related: sun::ast::MemberAssignmentAST

serializeMethodFunction

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeMethodFunction(const sun::ast::FunctionAST &function, pbc::FunctionDef *proto) const

The function behind a class or interface method.

Related: sun::ast::FunctionAST

serializeModule

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeModule(const sun::ast::ModuleAST &expr, pbc::ASTNode *node) const

Encodes a module declaration and its child data in the protobuf syntax representation.

Related: sun::ast::ModuleAST

serializeNumber

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeNumber(const sun::ast::NumberExprAST &expr, pbc::ASTNode *node) const

Individual node type serializers (dispatch by ASTNodeType).

Related: sun::ast::NumberExprAST, ASTNodeType

serializePackExpansion

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializePackExpansion(const sun::ast::PackExpansionAST &expr, pbc::ASTNode *node) const

Encodes a variadic argument expansion and its child data in the protobuf syntax representation.

Related: sun::ast::PackExpansionAST

serializeParen

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeParen(const sun::ast::ParenExprAST &expr, pbc::ASTNode *node) const

Encodes a parenthesized expression and its child data in the protobuf syntax representation.

Related: sun::ast::ParenExprAST

serializePosition

private · function · Source (opens in a new tab)

pbc::Position sun::serialization::ASTSerializer::serializePosition(const sun::support::Position &pos) const

Position serialization.

Related: sun::support::Position, Position

serializeQualifiedName

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeQualifiedName(const sun::ast::QualifiedNameAST &expr, pbc::ASTNode *node) const

Encodes a qualified name and its child data in the protobuf syntax representation.

Related: sun::ast::QualifiedNameAST

serializeReferenceCreation

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeReferenceCreation(const sun::ast::ReferenceCreationAST &expr, pbc::ASTNode *node) const

Encodes a reference creation and its child data in the protobuf syntax representation.

Related: sun::ast::ReferenceCreationAST

serializeReturn

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeReturn(const sun::ast::ReturnExprAST &expr, pbc::ASTNode *node) const

Encodes a return statement and its child data in the protobuf syntax representation.

Related: sun::ast::ReturnExprAST

serializeSlice

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeSlice(const sun::ast::SliceExprAST &expr, pbc::ASTNode *node) const

Encodes a slice expression and its child data in the protobuf syntax representation.

Related: sun::ast::SliceExprAST

serializeSliceInto

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeSliceInto(const sun::ast::SliceExprAST &slice, pbc::SliceExpr *proto) const

One index of a subscript: a[i] and a[i..j] share a slice message.

Related: sun::ast::SliceExprAST

serializeString

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeString(const sun::ast::StringLiteralAST &expr, pbc::ASTNode *node) const

Encodes a string literal and its child data in the protobuf syntax representation.

Related: sun::ast::StringLiteralAST

serializeStructLiteral

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeStructLiteral(const sun::ast::StructLiteralAST &expr, pbc::ASTNode *node) const

Encodes a field initializer list and its child data in the protobuf syntax representation.

Related: sun::ast::StructLiteralAST

serializeTernary

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeTernary(const sun::ast::TernaryExprAST &expr, pbc::ASTNode *node) const

Encodes a conditional expression and its child data in the protobuf syntax representation.

Related: sun::ast::TernaryExprAST

serializeThrow

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeThrow(const sun::ast::ThrowExprAST &expr, pbc::ASTNode *node) const

Encodes a throw expression and its child data in the protobuf syntax representation.

Related: sun::ast::ThrowExprAST

serializeToken

private · function · Source (opens in a new tab)

pbc::Token sun::serialization::ASTSerializer::serializeToken(const sun::parsing::Token &token) const

Token serialization (for operators).

Related: sun::parsing::Token, Token

serializeTryCatch

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeTryCatch(const sun::ast::TryCatchExprAST &expr, pbc::ASTNode *node) const

Encodes a error handler and its child data in the protobuf syntax representation.

Related: sun::ast::TryCatchExprAST

serializeTypeAnnotation

private · function · Source (opens in a new tab)

pbc::TypeAnnotation sun::serialization::ASTSerializer::serializeTypeAnnotation(const sun::ast::TypeAnnotation &type) const

Type annotation serialization.

Related: sun::ast::TypeAnnotation

serializeTypeParameterInto

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeTypeParameterInto(const sun::ast::TypeParameter &parameter, pbc::TypeParameter *proto) const

Store a parameter and its optional constraint for any declaration kind.

Related: sun::ast::TypeParameter

serializeUnary

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeUnary(const sun::ast::UnaryExprAST &expr, pbc::ASTNode *node) const

Encodes a unary operation and its child data in the protobuf syntax representation.

Related: sun::ast::UnaryExprAST

serializeUnsafeBlock

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeUnsafeBlock(const sun::ast::UnsafeBlockAST &expr, pbc::ASTNode *node) const

Encodes a unsafe block and its child data in the protobuf syntax representation.

Related: sun::ast::UnsafeBlockAST

serializeUsing

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeUsing(const sun::ast::UsingAST &expr, pbc::ASTNode *node) const

Encodes a using declaration and its child data in the protobuf syntax representation.

Related: sun::ast::UsingAST

serializeVariableAssignment

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeVariableAssignment(const sun::ast::VariableAssignmentAST &expr, pbc::ASTNode *node) const

Encodes a variable assignment and its child data in the protobuf syntax representation.

Related: sun::ast::VariableAssignmentAST

serializeVariableCreation

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeVariableCreation(const sun::ast::VariableCreationAST &expr, pbc::ASTNode *node) const

Encodes a variable declaration and its child data in the protobuf syntax representation.

Related: sun::ast::VariableCreationAST

serializeVariableRef

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeVariableRef(const sun::ast::VariableReferenceAST &expr, pbc::ASTNode *node) const

Encodes a variable reference and its child data in the protobuf syntax representation.

Related: sun::ast::VariableReferenceAST

serializeWhile

private · function · Source (opens in a new tab)

void sun::serialization::ASTSerializer::serializeWhile(const sun::ast::WhileExprAST &expr, pbc::ASTNode *node) const

Encodes a while loop and its child data in the protobuf syntax representation.

Related: sun::ast::WhileExprAST

Private Fields

config_

private · variable · Source (opens in a new tab)

SerializerConfig sun::serialization::ASTSerializer::config_

No documentation comment.

Related: SerializerConfig