Sha256: 6f7edd636b7f4dbbf3e9bbabca6f6130cf56b4a5ab7b90eb9bfbc2d34fd856f6

Contents?: true

Size: 741 Bytes

Versions: 19

Compression:

Stored size: 741 Bytes

Contents

module Finitio
  module Syntax
    module AdType
      include Node

      capture :builtin_type_name

      def compile(factory)
        name      = builtin_type_name
        clazz     = name ? resolve_ruby_const(name.to_s) : nil
        contracts = compile_contracts(factory, clazz)
        contracts = unique_names!(contracts, "contract")
        factory.adt(clazz, contracts)
      end

      def compile_contracts(factory, clazz)
        captures[:contract].map{|c| c.compile(factory, clazz) }
      end

      def to_ast
        [ 
          :ad_type,
          builtin_type_name ? builtin_type_name.to_s : nil
        ] + captures[:contract].map(&:to_ast)
      end

    end # module AdType
  end # module Syntax
end # module Finitio

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finitio-0.12.0 lib/finitio/syntax/type/ad_type.rb
finitio-0.11.4 lib/finitio/syntax/type/ad_type.rb
finitio-0.11.3 lib/finitio/syntax/type/ad_type.rb
finitio-0.11.2 lib/finitio/syntax/type/ad_type.rb
finitio-0.11.1 lib/finitio/syntax/type/ad_type.rb
finitio-0.10.0 lib/finitio/syntax/type/ad_type.rb
finitio-0.9.1 lib/finitio/syntax/type/ad_type.rb
finitio-0.9.0 lib/finitio/syntax/type/ad_type.rb
finitio-0.8.0 lib/finitio/syntax/type/ad_type.rb
finitio-0.7.0 lib/finitio/syntax/type/ad_type.rb
finitio-0.7.0.pre.rc4 lib/finitio/syntax/type/ad_type.rb
finitio-0.7.0.pre.rc3 lib/finitio/syntax/type/ad_type.rb
finitio-0.7.0.pre.rc2 lib/finitio/syntax/type/ad_type.rb
finitio-0.7.0.pre.rc1 lib/finitio/syntax/type/ad_type.rb
finitio-0.6.1 lib/finitio/syntax/type/ad_type.rb
finitio-0.6.0 lib/finitio/syntax/type/ad_type.rb
finitio-0.5.2 lib/finitio/syntax/type/ad_type.rb
finitio-0.5.1 lib/finitio/syntax/type/ad_type.rb
finitio-0.5.0 lib/finitio/syntax/type/ad_type.rb