Class: Furnace::AVM2::Tokens::ControlFlowToken

Inherits:
Code::NonterminalToken
  • Object
show all
Defined in:
lib/furnace-avm2/source/implementation_tokens/control_flow_token.rb

Instance Method Summary collapse

Constructor Details

#initialize(origin, condition, body, options = {}) ⇒ ControlFlowToken

Returns a new instance of ControlFlowToken.



3
4
5
6
# File 'lib/furnace-avm2/source/implementation_tokens/control_flow_token.rb', line 3

def initialize(origin, condition, body, options={})
  super(origin, [condition, body], options)
  @condition, @body = condition, body
end

Instance Method Details

#keywordObject



8
9
10
# File 'lib/furnace-avm2/source/implementation_tokens/control_flow_token.rb', line 8

def keyword
  raise "reimplement ControlFlowToken#keyword in a subclass"
end

#to_structure(options = {}) ⇒ Object



21
22
23
# File 'lib/furnace-avm2/source/implementation_tokens/control_flow_token.rb', line 21

def to_structure(options={})
  structurize "#{keyword}(...) ...", options
end

#to_textObject



12
13
14
15
16
17
18
19
# File 'lib/furnace-avm2/source/implementation_tokens/control_flow_token.rb', line 12

def to_text
  header = "#{keyword}(#{@condition.to_text})"
  if @body.is_a? ScopeToken
    "#{header} #{@body.to_text}"
  else
    "#{header}\n#{indent @body.to_text}"
  end
end