Class: Odin::Transform::TransformDef

Inherits:
Object
  • Object
show all
Defined in:
lib/odin/transform/transform_types.rb

Overview

Transform definition — top-level AST node

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header:, segments: [], constants: {}, tables: {}, accumulators: {}, passes: [], imports: []) ⇒ TransformDef

Returns a new instance of TransformDef.



63
64
65
66
67
68
69
70
71
# File 'lib/odin/transform/transform_types.rb', line 63

def initialize(header:, segments: [], constants: {}, tables: {}, accumulators: {}, passes: [], imports: [])
  @header = header
  @segments = segments
  @constants = constants
  @tables = tables
  @accumulators = accumulators
  @passes = passes
  @imports = imports
end

Instance Attribute Details

#accumulatorsObject (readonly)

Returns the value of attribute accumulators.



61
62
63
# File 'lib/odin/transform/transform_types.rb', line 61

def accumulators
  @accumulators
end

#constantsObject (readonly)

Returns the value of attribute constants.



61
62
63
# File 'lib/odin/transform/transform_types.rb', line 61

def constants
  @constants
end

#headerObject (readonly)

Returns the value of attribute header.



61
62
63
# File 'lib/odin/transform/transform_types.rb', line 61

def header
  @header
end

#importsObject (readonly)

Returns the value of attribute imports.



61
62
63
# File 'lib/odin/transform/transform_types.rb', line 61

def imports
  @imports
end

#passesObject (readonly)

Returns the value of attribute passes.



61
62
63
# File 'lib/odin/transform/transform_types.rb', line 61

def passes
  @passes
end

#segmentsObject (readonly)

Returns the value of attribute segments.



61
62
63
# File 'lib/odin/transform/transform_types.rb', line 61

def segments
  @segments
end

#tablesObject (readonly)

Returns the value of attribute tables.



61
62
63
# File 'lib/odin/transform/transform_types.rb', line 61

def tables
  @tables
end

Instance Method Details

#directionObject



73
74
75
# File 'lib/odin/transform/transform_types.rb', line 73

def direction
  header&.direction
end

#discriminator_configObject



87
88
89
# File 'lib/odin/transform/transform_types.rb', line 87

def discriminator_config
  header&.source_options&.dig("discriminator")
end

#source_formatObject



77
78
79
80
81
# File 'lib/odin/transform/transform_types.rb', line 77

def source_format
  # Prefer explicit source.format from {$source} section
  sf = header&.source_options&.dig("format")
  sf && !sf.empty? ? sf : Direction.source_format(direction)
end

#target_formatObject



83
84
85
# File 'lib/odin/transform/transform_types.rb', line 83

def target_format
  header&.target_format || Direction.target_format(direction)
end