Class: ClassNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/turmali/nodes.rb,
lib/turmali/interpreter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



44
45
46
# File 'lib/turmali/nodes.rb', line 44

def body
  @body
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



44
45
46
# File 'lib/turmali/nodes.rb', line 44

def name
  @name
end

Instance Method Details

#eval(context) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/turmali/interpreter.rb', line 103

def eval(context)
  turmali_class = Constants[name] 
  
  unless turmali_class 
    turmali_class = TurmaliClass.new
    Constants[name] = turmali_class 
  end
  
  class_context = Context.new(turmali_class, turmali_class)
  body.eval(class_context)
  
  turmali_class
end