Module: Liquidscript::Compiler::ICR::Helpers
- Included in:
- Liquidscript::Compiler::ICR
- Defined in:
- lib/liquidscript/compiler/icr/helpers.rb
Instance Method Summary collapse
- #code(type, *args) ⇒ Object
- #ref(literal) ⇒ Object
- #set(literal) ⇒ Object
- #value_expect(v, &default) ⇒ Object
Instance Method Details
#code(type, *args) ⇒ Object
14 15 16 |
# File 'lib/liquidscript/compiler/icr/helpers.rb', line 14 def code(type, *args) Liquidscript::ICR::Code.new type, *args end |
#ref(literal) ⇒ Object
6 7 8 |
# File 'lib/liquidscript/compiler/icr/helpers.rb', line 6 def ref(literal) top.context.get(literal.value.intern) end |
#set(literal) ⇒ Object
10 11 12 |
# File 'lib/liquidscript/compiler/icr/helpers.rb', line 10 def set(literal) top.context.set(literal.value.intern) end |
#value_expect(v, &default) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/liquidscript/compiler/icr/helpers.rb', line 18 def value_expect(v, &default) out = expect \ :lparen => action { compile_call(v) }, :equal => action { compile_assignment(v) }, :prop => action { compile_property(v) }, :lbrack => action { compile_access(v) }, [:binop, :minus, :plus] => action { compile_binop(v) }, :unop => action { |o| code :op, v, o }, :_ => default || action { v } if out != v value_expect(out) else out end end |