Module: Jade::Symbol

Extended by:
Symbol
Included in:
Symbol, ValueRef
Defined in:
lib/jade/symbol.rb,
lib/jade/symbol/base.rb,
lib/jade/symbol/union.rb,
lib/jade/symbol/lambda.rb,
lib/jade/symbol/parser.rb,
lib/jade/symbol/struct.rb,
lib/jade/symbol/variant.rb,
lib/jade/symbol/function.rb,
lib/jade/symbol/type_ref.rb,
lib/jade/symbol/variable.rb,
lib/jade/symbol/interface.rb,
lib/jade/symbol/value_ref.rb,
lib/jade/symbol/constructor.rb,
lib/jade/symbol/record_type.rb,
lib/jade/symbol/function_type.rb,
lib/jade/symbol/implementation.rb,
lib/jade/symbol/stdlib_function.rb,
lib/jade/symbol/anonymous_record.rb,
lib/jade/symbol/derived_function.rb,
lib/jade/symbol/interop_function.rb,
lib/jade/symbol/type_application.rb,
lib/jade/symbol/interface_function.rb,
lib/jade/symbol/partial_application.rb,
lib/jade/symbol/stdlib_implementation.rb,
lib/jade/symbol/implementation_template.rb

Defined Under Namespace

Modules: Base, Parser Classes: AnonymousRecord, Constructor, DerivedFunction, Function, FunctionType, Implementation, ImplementationTemplate, Interface, InterfaceFunction, InteropFunction, Lambda, PartialApplication, RecordType, StdlibFunction, StdlibImplementation, Struct, TypeApplication, TypeRef, Union, ValueRef, Variable, Variant

Instance Method Summary collapse

Instance Method Details

#anonymous_record(fields, row_var = nil) ⇒ Object



40
41
42
43
44
# File 'lib/jade/symbol.rb', line 40

def anonymous_record(fields, row_var = nil)
  fail('fields is expected to be an array') unless fields.is_a?(Array)

  AnonymousRecord[fields, row_var]
end

#constructor(name, args, parent, span) ⇒ Object



60
61
62
# File 'lib/jade/symbol.rb', line 60

def constructor(name, args, parent, span)
  Constructor[nil, name, args, parent, span]
end

#function(name, params, return_type, decl_span = nil) ⇒ Object



93
94
95
# File 'lib/jade/symbol.rb', line 93

def function(name, params, return_type, decl_span = nil)
  Function[nil, name, params, return_type, decl_span]
end

#function_type(params, return_type) ⇒ Object



97
98
99
# File 'lib/jade/symbol.rb', line 97

def function_type(params, return_type)
  FunctionType[params, return_type]
end

#implementation(interface, type, type_params, constraints, functions, deps, span, extends: []) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/jade/symbol.rb', line 133

def implementation(
  interface,
  type,
  type_params,
  constraints,
  functions,
  deps,
  span,
  extends: []
)
  Implementation[
    nil,
    interface,
    type,
    type_params,
    constraints,
    functions,
    deps,
    extends,
    span,
  ]
end

#interface(name, type_var, functions, default, span) ⇒ Object



125
126
127
# File 'lib/jade/symbol.rb', line 125

def interface(name, type_var, functions, default, span)
  Interface[nil, name, type_var, functions, default, span]
end

#interface_function(name, inteface, params, return_type, span) ⇒ Object



129
130
131
# File 'lib/jade/symbol.rb', line 129

def interface_function(name, inteface, params, return_type, span)
  InterfaceFunction[nil, name, inteface, params, return_type, span]
end

#interop_function(name, params, return_type, interop_module_name, constraints: []) ⇒ Object



109
110
111
# File 'lib/jade/symbol.rb', line 109

def interop_function(name, params, return_type, interop_module_name, constraints: [])
  InteropFunction[nil, name, params, return_type, interop_module_name, constraints, nil]
end

#lambda(arity) ⇒ Object



68
69
70
# File 'lib/jade/symbol.rb', line 68

def lambda(arity)
  Lambda[arity]
end

#module_name(qualified_name) ⇒ Object



31
32
33
34
# File 'lib/jade/symbol.rb', line 31

def module_name(qualified_name)
  *module_parts, _ = qualified_name
  module_parts.join('.')
end

#parse(annotation) ⇒ Object



156
157
158
159
160
# File 'lib/jade/symbol.rb', line 156

def parse(annotation)
  Lexer
    .tokenize(Source.new(uri: nil, text: annotation))
    .then { Parser.parse(it) }
end

#partial_application(constructor, args, span) ⇒ Object



117
118
119
# File 'lib/jade/symbol.rb', line 117

def partial_application(constructor, args, span)
  PartialApplication[constructor, args, span]
end

#predeclared_constructor(name, span) ⇒ Object



64
65
66
# File 'lib/jade/symbol.rb', line 64

def predeclared_constructor(name, span)
  Constructor[nil, name, [], nil, span]
end

#predeclared_function(name, decl_span = nil) ⇒ Object



89
90
91
# File 'lib/jade/symbol.rb', line 89

def predeclared_function(name, decl_span = nil)
  Function[nil, name, nil, nil, decl_span]
end

#predeclared_interop_function(name) ⇒ Object



105
106
107
# File 'lib/jade/symbol.rb', line 105

def predeclared_interop_function(name)
  InteropFunction[nil, name, [], nil, nil, [], nil]
end

#predeclared_struct(name, type_params, span) ⇒ Object



121
122
123
# File 'lib/jade/symbol.rb', line 121

def predeclared_struct(name, type_params, span)
  Struct[nil, name, type_params, nil, span]
end

#record_type(fields, row_var) ⇒ Object



46
47
48
49
50
# File 'lib/jade/symbol.rb', line 46

def record_type(fields, row_var)
  fail('fields is expected to be a hash') unless fields.is_a?(Hash)

  RecordType[fields, row_var]
end

#stdlib_function(name, params, return_type, codegen, constraints: []) ⇒ Object



101
102
103
# File 'lib/jade/symbol.rb', line 101

def stdlib_function(name, params, return_type, codegen, constraints: [])
  StdlibFunction[nil, name, params, return_type, codegen, constraints]
end

#type_application(constructor, args, span) ⇒ Object



113
114
115
# File 'lib/jade/symbol.rb', line 113

def type_application(constructor, args, span)
  TypeApplication[constructor, args, span]
end

#type_ref(module_name, name) ⇒ Object



72
73
74
# File 'lib/jade/symbol.rb', line 72

def type_ref(module_name, name)
  TypeRef[module_name, name]
end

#type_ref_from_qualified_name(q_name) ⇒ Object



76
77
78
79
# File 'lib/jade/symbol.rb', line 76

def type_ref_from_qualified_name(q_name)
  *qualified_parts, name = q_name.split('.')
  TypeRef[qualified_parts.join('.'), name]
end

#union(name, type_params, variants, span) ⇒ Object



52
53
54
# File 'lib/jade/symbol.rb', line 52

def union(name, type_params, variants, span)
  Union[nil, name, type_params, variants.map(&:to_ref), span]
end

#unqualified_name(qualified_name) ⇒ Object



36
37
38
# File 'lib/jade/symbol.rb', line 36

def unqualified_name(qualified_name)
  qualified_name.split('.').last
end

#value_ref(module_name, name) ⇒ Object



81
82
83
# File 'lib/jade/symbol.rb', line 81

def value_ref(module_name, name)
  ValueRef[module_name, name]
end

#var(name, span) ⇒ Object



85
86
87
# File 'lib/jade/symbol.rb', line 85

def var(name, span)
  Variable[name, span]
end

#variant(name, args, union, span) ⇒ Object



56
57
58
# File 'lib/jade/symbol.rb', line 56

def variant(name, args, union, span)
  Variant[nil, name, args, union, span]
end