Module: Liquidscript::Compiler::ICR::Functions
- Included in:
- Liquidscript::Compiler::ICR
- Defined in:
- lib/liquidscript/compiler/icr/functions.rb
Instance Method Summary collapse
- #compile_access(body) ⇒ Object
- #compile_call(subject) ⇒ Object
- #compile_function_with_parameters(parameters) ⇒ Object
- #compile_property(prop) ⇒ Object
Instance Method Details
#compile_access(body) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/liquidscript/compiler/icr/functions.rb', line 19 def compile_access(body) shift :lbrack key = compile_vexpression shift :rbrack v = code :access, body, key v end |
#compile_call(subject) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/liquidscript/compiler/icr/functions.rb', line 29 def compile_call(subject) shift :lparen if subject.type == :identifier ref(subject) end arguments = collect_compiles :expression, :rparen, :comma => action.shift call = code :call, subject, *arguments call end |
#compile_function_with_parameters(parameters) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/liquidscript/compiler/icr/functions.rb', line 44 def compile_function_with_parameters(parameters) shift :arrow expressions = _build_set(parameters) if peek?(:lbrace) shift :lbrace collect_compiles(:rbrace) do expressions << compile_expression end else expressions << compile_expression end code :function, @set.pop end |
#compile_property(prop) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/liquidscript/compiler/icr/functions.rb', line 6 def compile_property(prop) shift :prop property = action do |ident| code :property, prop, (ident.value || ident.type) end # Just in case there is a property named 'class' or 'module' v = expect [:identifier, :class, :module] => property v end |