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
17 18 19 20 21 22 23 |
# File 'lib/liquidscript/compiler/icr/functions.rb', line 17 def compile_access(body) shift :lbrack key = compile_vexpression shift :rbrack code :access, body, key end |
#compile_call(subject) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/liquidscript/compiler/icr/functions.rb', line 25 def compile_call(subject) shift :lparen if subject.type == :identifier ref(subject) end arguments = collect_compiles :expression, :rparen, :comma => action.shift code :call, subject, *arguments end |
#compile_function_with_parameters(parameters) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/liquidscript/compiler/icr/functions.rb', line 39 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 |
# 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' expect [:identifier, :class, :module] => property end |