Class: TPPlus::Nodes::LabelDefinitionNode

Inherits:
BaseNode
  • Object
show all
Defined in:
lib/tp_plus/nodes/label_definition_node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseNode

#can_be_inlined?

Constructor Details

#initialize(identifier) ⇒ LabelDefinitionNode

Returns a new instance of LabelDefinitionNode.



5
6
7
# File 'lib/tp_plus/nodes/label_definition_node.rb', line 5

def initialize(identifier)
  @identifier = identifier
end

Instance Attribute Details

#identifierObject (readonly)

Returns the value of attribute identifier.



4
5
6
# File 'lib/tp_plus/nodes/label_definition_node.rb', line 4

def identifier
  @identifier
end

Instance Method Details

#eval(context) ⇒ Object



15
16
17
18
# File 'lib/tp_plus/nodes/label_definition_node.rb', line 15

def eval(context)
  #context.add_label(@identifier)
  "LBL[#{context.labels[@identifier.to_sym]}:#{@identifier[0,16]}]#{long_identifier_comment(context)}"
end

#long_identifier_comment(context) ⇒ Object



9
10
11
12
13
# File 'lib/tp_plus/nodes/label_definition_node.rb', line 9

def long_identifier_comment(context)
  return "" unless @identifier.length > 16

  " ;\n! #{@identifier}"
end