RPNXCortado
C++23 JVM class-file, bytecode, validation, and JAR toolkit
Loading...
Searching...
No Matches
rpnx::cortado::class_file_builder Class Reference

An owning symbolic class-file builder with a shared constant-pool interner. More...

#include <builders.hpp>

Public Member Functions

 class_file_builder (std::string_view class_name, std::string_view super_class_name="java/lang/Object", class_file_version version={0, 70})
 Creates a new class with the supplied internal names.
 
 class_file_builder (class_file value)
 Initializes a builder from an exact parsed class model.
 
auto access_flags () noexcept -> class_access_flags &
 Returns the mutable class access flags.
 
auto version () noexcept -> class_file_version &
 Returns the mutable class-file version.
 
auto constant_pool () noexcept -> constant_pool_builder &
 Returns the shared constant-pool interner.
 
auto add_interface (std::string_view internal_name) -> class_file_builder &
 Adds an implemented or extended interface by internal class name.
 
auto fields () noexcept -> std::vector< field_info > &
 Returns the mutable exact field sequence for transformations.
 
auto methods () noexcept -> std::vector< method_info > &
 Returns the mutable exact method sequence for transformations.
 
auto attributes () noexcept -> std::vector< class_attribute > &
 Returns the mutable typed class-attribute sequence for transformations.
 
auto add_method (std::string_view name, std::string_view descriptor, method_access_flags flags, code_builder const &code, code_build_options const &options={}, class_hierarchy_resolver_ref hierarchy={}) -> method_info &
 Adds a method with a symbolic Code body.
 
auto add_field (std::string_view name, std::string_view descriptor, field_access_flags flags) -> field_info &
 Adds a field without attributes.
 
class_file build () const
 Returns a complete exact class-file model.
 

Detailed Description

An owning symbolic class-file builder with a shared constant-pool interner.

The builder owns its class model and interns names and references in one deterministic pool. References returned from mutable accessors follow normal std::vector invalidation rules.

Definition at line 672 of file builders.hpp.

Constructor & Destructor Documentation

◆ class_file_builder() [1/2]

rpnx::cortado::class_file_builder::class_file_builder ( std::string_view class_name,
std::string_view super_class_name = "java/lang/Object",
class_file_version version = {0, 70} )
explicit

Creates a new class with the supplied internal names.

Parameters
class_nameSlash-separated internal name of the new class.
super_class_nameDirect superclass internal name.
versionClass-file version to emit.

References version().

Referenced by add_interface().

◆ class_file_builder() [2/2]

rpnx::cortado::class_file_builder::class_file_builder ( class_file value)
explicit

Initializes a builder from an exact parsed class model.

Parameters
valueModel whose existing constant-pool indexes and ordering are retained.
Exceptions
validation_errorif its constant pool cannot initialize the interner.

Member Function Documentation

◆ access_flags()

auto rpnx::cortado::class_file_builder::access_flags ( ) -> class_access_flags &
nodiscardnoexcept

Returns the mutable class access flags.

Returns
Reference into the owned class model.

◆ add_field()

auto rpnx::cortado::class_file_builder::add_field ( std::string_view name,
std::string_view descriptor,
field_access_flags flags ) -> field_info &

Adds a field without attributes.

Parameters
nameJVM field name.
descriptorComplete JVM field descriptor bytes.
flagsField access flags.
Returns
Reference to the appended field; later vector growth may invalidate it.

◆ add_interface()

auto rpnx::cortado::class_file_builder::add_interface ( std::string_view internal_name) -> class_file_builder &

Adds an implemented or extended interface by internal class name.

Parameters
internal_nameSlash-separated interface internal name.
Returns
*this.

References add_interface(), and class_file_builder().

Referenced by add_interface().

◆ add_method()

auto rpnx::cortado::class_file_builder::add_method ( std::string_view name,
std::string_view descriptor,
method_access_flags flags,
code_builder const & code,
code_build_options const & options = {},
class_hierarchy_resolver_ref hierarchy = {} ) -> method_info &

Adds a method with a symbolic Code body.

Parameters
nameJVM method name.
descriptorComplete JVM method descriptor.
flagsMethod access flags.
codeSymbolic code to finalize against this class's shared pool.
optionsAnalysis and metadata policy.
hierarchyOptional resolver for verifier reference merges.
Returns
Reference to the appended method; later vector growth may invalidate it.
Exceptions
parse_errorif descriptor is malformed.
assembly_errorif the code cannot be finalized.

References add_method().

Referenced by add_method().

◆ attributes()

auto rpnx::cortado::class_file_builder::attributes ( ) -> std::vector< class_attribute > &
nodiscardnoexcept

Returns the mutable typed class-attribute sequence for transformations.

Returns
Reference into the owned class model.

References attributes().

Referenced by attributes().

◆ build()

class_file rpnx::cortado::class_file_builder::build ( ) const
nodiscard

Returns a complete exact class-file model.

Returns
Copy of the owned model with the interner's current entry sequence installed.

◆ constant_pool()

auto rpnx::cortado::class_file_builder::constant_pool ( ) -> constant_pool_builder &
nodiscardnoexcept

Returns the shared constant-pool interner.

Returns
Mutable interner used by all subsequent builder operations.

References constant_pool().

Referenced by constant_pool().

◆ fields()

auto rpnx::cortado::class_file_builder::fields ( ) -> std::vector< field_info > &
nodiscardnoexcept

Returns the mutable exact field sequence for transformations.

Returns
Reference into the owned class model.

References fields().

Referenced by fields().

◆ methods()

auto rpnx::cortado::class_file_builder::methods ( ) -> std::vector< method_info > &
nodiscardnoexcept

Returns the mutable exact method sequence for transformations.

Returns
Reference into the owned class model.

References methods().

Referenced by methods().

◆ version()

auto rpnx::cortado::class_file_builder::version ( ) -> class_file_version &
nodiscardnoexcept

Returns the mutable class-file version.

Returns
Reference into the owned class model.

References version().

Referenced by class_file_builder(), and version().


The documentation for this class was generated from the following file: