Class: Pione::Lang::ParamContext
- Inherits:
-
StructuralContext
- Object
- StructX
- Context
- StructuralContext
- Pione::Lang::ParamContext
- Defined in:
- lib/pione/lang/context.rb
Overview
ParamContext is a context for parameter block. This context takes special interpretation of variable binding declaration.
Instance Method Summary collapse
- #eval(env) ⇒ Object
-
#transform(declaration) ⇒ Object
Trasform variable binding declarations into param declarations.
Methods inherited from StructuralContext
#+, accept, acceptances, inherited, #initialize, #pos, #try_to_eval, #validate
Methods inherited from Context
Constructor Details
This class inherits a constructor from Pione::Lang::StructuralContext
Instance Method Details
#eval(env) ⇒ Object
139 140 141 142 143 144 145 |
# File 'lib/pione/lang/context.rb', line 139 def eval(env) if elements.any? {|elt| elt.is_a?(VariableBindingDeclaration)} set(elements: elements.map {|elt| transform(elt)}).eval(env) else super end end |
#transform(declaration) ⇒ Object
Trasform variable binding declarations into param declarations.
148 149 150 151 152 153 154 |
# File 'lib/pione/lang/context.rb', line 148 def transform(declaration) if declaration.is_a?(VariableBindingDeclaration) ParamDeclaration.new(type, declaration.expr1, declaration.expr2) else declaration end end |