Sha256: 202fe544af80436d2e2816ced513078ffd91dce6fab8e53909796000e0be0ce8

Contents?: true

Size: 1.38 KB

Versions: 17

Compression:

Stored size: 1.38 KB

Contents

require "liquidscript/compiler/icr/expressions"
require "liquidscript/compiler/icr/functions"
require "liquidscript/compiler/icr/literals"
require "liquidscript/compiler/icr/classes"
require "liquidscript/compiler/icr/helpers"
require "liquidscript/compiler/icr/heredoc"

module Liquidscript
  module Compiler
    class ICR < Base

      include Expressions
      include Functions
      include Literals
      include Classes
      include Helpers

      # (see Base#initialize)
      def initialize(*)
        super

        handle_directives
      end

      # (see Base#reset!)
      def reset!
        @top         = Liquidscript::ICR::Set.new
        @top.context = Liquidscript::ICR::Context.new
        @set         = [@top]
        super
      end

      # (see Base#top)
      def top
        @set.last
      end

      # Sets the starting point for compiliation.
      #
      # @return [ICR::Code]
      def compile_start
        compile_expression
      end

      private

      def handle_directives
        return unless @scanner.metadata[:directives]

        @scanner.metadata[:directives].each do |meta|
          case meta[:command]
          when "allow"
            variables = meta[:args].split(' ')
            variables.each { |v| top.context.allow(v.intern) }
          else
            raise UnknownDirectiveError.new(meta[:command])
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
liquidscript-0.7.12 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.11 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.10 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.9 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.8 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.7 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.6 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.5 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.4 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.3 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.2 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.1 lib/liquidscript/compiler/icr.rb
liquidscript-0.7.0 lib/liquidscript/compiler/icr.rb
liquidscript-0.6.5 lib/liquidscript/compiler/icr.rb
liquidscript-0.6.4 lib/liquidscript/compiler/icr.rb
liquidscript-0.6.3 lib/liquidscript/compiler/icr.rb
liquidscript-0.6.2 lib/liquidscript/compiler/icr.rb