Module: Finitio::Syntax::SubType

Includes:
Node
Defined in:
lib/finitio/syntax/type/sub_type.rb

Instance Method Summary collapse

Methods included from Node

included, #metadata, #resolve_ruby_const, #unique_names!

Instance Method Details

#compile(factory) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/finitio/syntax/type/sub_type.rb', line 8

def compile(factory)
  s = rel_type.compile(factory)
  if c = constraint_def
    factory.subtype(s, c.compile(factory))
  else
    s
  end
end

#to_astObject



17
18
19
20
21
22
23
# File 'lib/finitio/syntax/type/sub_type.rb', line 17

def to_ast
  if c = constraint_def
    [:sub_type, rel_type.to_ast] + constraint_def.to_ast
  else
    rel_type.to_ast
  end
end