Class: Odin::Transform::VerbContext
- Inherits:
-
Object
- Object
- Odin::Transform::VerbContext
- Defined in:
- lib/odin/transform/verb_context.rb
Constant Summary collapse
- MAX_LOOP_DEPTH =
10
Instance Attribute Summary collapse
-
#accumulators ⇒ Object
DynValue — current source root.
-
#aliases ⇒ Object
DynValue — current source root.
-
#constants ⇒ Object
DynValue — current source root.
-
#current_item ⇒ Object
DynValue — current source root.
-
#errors ⇒ Object
DynValue — current source root.
-
#field_modifiers ⇒ Object
DynValue — current source root.
-
#global_output ⇒ Object
DynValue — current source root.
-
#loop_depth ⇒ Object
DynValue — current source root.
-
#loop_index ⇒ Object
DynValue — current source root.
-
#loop_length ⇒ Object
DynValue — current source root.
-
#loop_vars ⇒ Object
DynValue — current source root.
-
#on_error ⇒ Object
DynValue — current source root.
-
#on_missing ⇒ Object
DynValue — current source root.
-
#on_validation ⇒ Object
DynValue — current source root.
-
#sequences ⇒ Object
DynValue — current source root.
-
#source ⇒ Object
DynValue — current source root.
-
#source_format ⇒ Object
DynValue — current source root.
-
#strict_types ⇒ Object
DynValue — current source root.
-
#tables ⇒ Object
DynValue — current source root.
-
#warnings ⇒ Object
DynValue — current source root.
Instance Method Summary collapse
- #dup_for_loop ⇒ Object
- #get_accumulator(name) ⇒ Object
- #get_constant(name) ⇒ Object
- #get_table(name) ⇒ Object
- #in_loop? ⇒ Boolean
-
#initialize ⇒ VerbContext
constructor
A new instance of VerbContext.
- #next_sequence(name) ⇒ Object
- #reset_sequence(name) ⇒ Object
- #set_accumulator(name, value) ⇒ Object
Constructor Details
#initialize ⇒ VerbContext
Returns a new instance of VerbContext.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/odin/transform/verb_context.rb', line 29 def initialize @source = Types::DynValue.of_null @current_item = nil @loop_index = 0 @loop_length = 0 @loop_vars = {} @aliases = {} @accumulators = {} @tables = {} @constants = {} @global_output = {} @sequences = {} @loop_depth = 0 @field_modifiers = {} @errors = [] @warnings = [] @source_format = "" @on_validation = nil @on_missing = nil @on_error = nil @strict_types = false end |
Instance Attribute Details
#accumulators ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def accumulators @accumulators end |
#aliases ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def aliases @aliases end |
#constants ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def constants @constants end |
#current_item ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def current_item @current_item end |
#errors ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def errors @errors end |
#field_modifiers ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def field_modifiers @field_modifiers end |
#global_output ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def global_output @global_output end |
#loop_depth ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def loop_depth @loop_depth end |
#loop_index ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def loop_index @loop_index end |
#loop_length ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def loop_length @loop_length end |
#loop_vars ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def loop_vars @loop_vars end |
#on_error ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def on_error @on_error end |
#on_missing ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def on_missing @on_missing end |
#on_validation ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def on_validation @on_validation end |
#sequences ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def sequences @sequences end |
#source ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def source @source end |
#source_format ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def source_format @source_format end |
#strict_types ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def strict_types @strict_types end |
#tables ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def tables @tables end |
#warnings ⇒ Object
DynValue — current source root
6 7 8 |
# File 'lib/odin/transform/verb_context.rb', line 6 def warnings @warnings end |
Instance Method Details
#dup_for_loop ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/odin/transform/verb_context.rb', line 83 def dup_for_loop ctx = VerbContext.new ctx.source = @source ctx.loop_vars = @loop_vars.dup ctx.aliases = @aliases.dup ctx.accumulators = @accumulators # shared reference ctx.tables = @tables ctx.constants = @constants ctx.global_output = @global_output # shared reference ctx.sequences = @sequences # shared reference ctx.loop_depth = @loop_depth + 1 ctx.field_modifiers = @field_modifiers # shared reference ctx.errors = @errors # shared reference ctx.warnings = @warnings # shared reference ctx.source_format = @source_format ctx.on_validation = @on_validation ctx.on_missing = @on_missing ctx.on_error = @on_error ctx end |
#get_accumulator(name) ⇒ Object
63 64 65 |
# File 'lib/odin/transform/verb_context.rb', line 63 def get_accumulator(name) @accumulators[name] || Types::DynValue.of_null end |
#get_constant(name) ⇒ Object
71 72 73 |
# File 'lib/odin/transform/verb_context.rb', line 71 def get_constant(name) @constants[name] || Types::DynValue.of_null end |
#get_table(name) ⇒ Object
75 76 77 |
# File 'lib/odin/transform/verb_context.rb', line 75 def get_table(name) @tables[name] end |
#in_loop? ⇒ Boolean
79 80 81 |
# File 'lib/odin/transform/verb_context.rb', line 79 def in_loop? !@current_item.nil? end |
#next_sequence(name) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/odin/transform/verb_context.rb', line 52 def next_sequence(name) @sequences[name] ||= 0 val = @sequences[name] @sequences[name] += 1 val end |
#reset_sequence(name) ⇒ Object
59 60 61 |
# File 'lib/odin/transform/verb_context.rb', line 59 def reset_sequence(name) @sequences[name] = 0 end |
#set_accumulator(name, value) ⇒ Object
67 68 69 |
# File 'lib/odin/transform/verb_context.rb', line 67 def set_accumulator(name, value) @accumulators[name] = value end |