Class: ClassNode
- Inherits:
-
Struct
- Object
- Struct
- ClassNode
- Defined in:
- lib/toylang/ast/nodes.rb,
lib/toylang/interpreter/evaluation.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#name ⇒ Object
Returns the value of attribute name.
-
#superclass ⇒ Object
Returns the value of attribute superclass.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body
43 44 45 |
# File 'lib/toylang/ast/nodes.rb', line 43 def body @body end |
#name ⇒ Object
Returns the value of attribute name
43 44 45 |
# File 'lib/toylang/ast/nodes.rb', line 43 def name @name end |
#superclass ⇒ Object
Returns the value of attribute superclass
43 44 45 |
# File 'lib/toylang/ast/nodes.rb', line 43 def superclass @superclass end |
Instance Method Details
#eval(context) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/toylang/interpreter/evaluation.rb', line 100 def eval(context) toylang_class = context[name] unless toylang_class toylang_class = ToyLangClass.new(Runtime[superclass || 'Object']) context[name] = toylang_class end class_context = Context.new(toylang_class, toylang_class) body.eval(class_context) toylang_class end |