Class: Zaid::Nodes::ClassNode

Inherits:
Struct
  • Object
show all
Defined in:
lib/zaid/nodes/class_node.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



5
6
7
# File 'lib/zaid/nodes/class_node.rb', line 5

def body
  @body
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/zaid/nodes/class_node.rb', line 5

def name
  @name
end

Instance Method Details

#eval(_context) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/zaid/nodes/class_node.rb', line 6

def eval(_context)
  zaid_class = Constants[name]

  unless zaid_class
    zaid_class = Runtime::ZaidClass.new(Constants['شيء'])
    Constants[name] = zaid_class
  end

  class_context = Runtime::Context.new(zaid_class, zaid_class)
  body.eval(class_context)

  zaid_class
end