Module: Liquidscript::Compiler::ICR::Functions

Included in:
Liquidscript::Compiler::ICR
Defined in:
lib/liquidscript/compiler/icr/functions.rb

Instance Method Summary collapse

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_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