Class: Metal::Generator::Expression
- Inherits:
-
Object
- Object
- Metal::Generator::Expression
- Defined in:
- lib/metal/generator.rb
Instance Method Summary collapse
- #generate(ctx, source) ⇒ Object
-
#initialize(pred, iter, var) ⇒ Expression
constructor
A new instance of Expression.
- #preprocess(ctx) ⇒ Object
Constructor Details
#initialize(pred, iter, var) ⇒ Expression
Returns a new instance of Expression.
262 263 264 265 266 |
# File 'lib/metal/generator.rb', line 262 def initialize(pred, iter, var) @pred = pred @iter = iter @var = var end |
Instance Method Details
#generate(ctx, source) ⇒ Object
271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/metal/generator.rb', line 271 def generate(ctx, source) source << "env[PARAM_#{@var}] = ({\n" if @var if @iter obj = ctx.rule.with_lambda(source) { @pred.generate(ctx, source) } source << "ctx->act_#{@iter}(&#{obj});\n" else @pred.generate(ctx, source) end source << "});\n" if @var end |
#preprocess(ctx) ⇒ Object
267 268 269 270 |
# File 'lib/metal/generator.rb', line 267 def preprocess(ctx) ctx.register_var(@var) if @var @pred.preprocess(ctx) end |