finitio 0.11.3 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +42 -19
- data/Gemfile.lock +18 -18
- data/finitio.gemspec +3 -3
- data/lib/finitio/generation/proxy_type.rb +11 -0
- data/lib/finitio/generation.rb +1 -0
- data/lib/finitio/json_schema/builtin_type.rb +0 -2
- data/lib/finitio/json_schema/hash_based_type.rb +1 -1
- data/lib/finitio/json_schema/proxy_type.rb +4 -5
- data/lib/finitio/stdlib/finitio/data.fio +2 -2
- data/lib/finitio/support/compilation.rb +0 -4
- data/lib/finitio/support/proxy_resolver.rb +52 -0
- data/lib/finitio/support.rb +1 -0
- data/lib/finitio/syntax.rb +4 -4
- data/lib/finitio/system.rb +5 -16
- data/lib/finitio/type/ad_type.rb +1 -1
- data/lib/finitio/type/builtin_type.rb +4 -4
- data/lib/finitio/type/high_order_type.rb +3 -1
- data/lib/finitio/type/proxy_type.rb +19 -1
- data/lib/finitio/type/struct_type.rb +2 -2
- data/lib/finitio/type/sub_type.rb +2 -2
- data/lib/finitio/type/tuple_type.rb +3 -3
- data/lib/finitio/type/union_type.rb +2 -2
- data/lib/finitio/type.rb +4 -2
- data/lib/finitio/version.rb +2 -2
- data/spec/finitio/test_ast.rb +2 -2
- data/spec/finitio/test_parse.rb +1 -1
- data/spec/finitio/test_system.rb +1 -1
- data/spec/inference/test_inference.rb +1 -1
- data/spec/json_schema/test_builtin_type.rb +4 -6
- data/spec/json_schema/test_recursive_type.rb +2 -12
- data/spec/regression/test_dress_on_recursive_type.rb +53 -0
- data/spec/regression/test_name_of_generic_types.rb +18 -0
- data/spec/syntax/test_compile.rb +19 -1
- data/spec/type_factory/factory/test_sub_type.rb +3 -3
- metadata +175 -170
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 92c67dd32e89dd6c4597b4a8456572bb1a5b3de07bdf58e88bcb9dc3f0874462
|
4
|
+
data.tar.gz: 4ecd7898e477113040613415f9bc2cc8f23bc3605d0f71a3ccaefbbe1eaf31ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb3042b639a82d469bb760807e6c94e1f70c39a3249420d30e339d5f004048e8abe6026de3b3b834e3703f88b3dd10a6d2937abdba5a183444af13609cc150b5
|
7
|
+
data.tar.gz: f44c30f37848ad1e0b8344487cc0f0353ad694ce31c535ff6dd4ae02e903bebc92d11b29ac78ae0aa7d21f7bce6ba3fbd7ecdceb2cb6d14aa4bd3f9d6fb5164a
|
data/CHANGELOG.md
CHANGED
@@ -1,24 +1,47 @@
|
|
1
|
-
|
1
|
+
## 0.12.0 - 2023/05/23
|
2
|
+
|
3
|
+
* Remove support for ruby < 2.6
|
4
|
+
|
5
|
+
* Remove support for .Fixnum and .Bignum, .Integer is now used
|
6
|
+
everywhere. To ease the transition, Fixum and Bignum still exist
|
7
|
+
in the finitio/data stdlib schema, but will be removed in 0.13.x
|
8
|
+
|
9
|
+
## 0.11.4 - 2023/01/06
|
10
|
+
|
11
|
+
* The proxy resolution is fixed and clarified. When compiling
|
12
|
+
a system, all proxies are actually replaced by their actual
|
13
|
+
Type instance. Only recursive types still keep ProxyType
|
14
|
+
instances (as sentinels) ; they are bound to their target
|
15
|
+
type and delete dress and include? to them.
|
16
|
+
|
17
|
+
Given that ProxyType is a sentinel on recursive types, calls
|
18
|
+
to generate_data and to_json_schema are not delegated to the
|
19
|
+
target type, to avoid infinite recursions.
|
20
|
+
|
21
|
+
* Generated names of instantiated high order types are better
|
22
|
+
(e.g. Collection<String>).
|
23
|
+
|
24
|
+
## 0.11.3 - 2023/01/06
|
2
25
|
|
3
26
|
* Fix json_schema generation on unresolved ProxyTypes. We use
|
4
27
|
"object" by default, waiting for a better support for recursive
|
5
28
|
types.
|
6
29
|
|
7
|
-
|
30
|
+
## 0.11.2 - 2023/01/06
|
8
31
|
|
9
32
|
* Fix json_schema generation on builtin_type NilClass. "null"
|
10
33
|
is not a valid value, we now use "string" instead.
|
11
34
|
|
12
|
-
|
35
|
+
## 0.11.1 - 2021/12/09
|
13
36
|
|
14
37
|
* Fix github actions and extend test grid.
|
15
38
|
|
16
|
-
|
39
|
+
## 0.11.0 - 2021/12/09
|
17
40
|
|
18
41
|
* Fix json schema generation of Boolean and union types with a |Nil
|
19
42
|
* Add support for dashses in attribute names (tuple & relation types).
|
20
43
|
|
21
|
-
|
44
|
+
## 0.10.0 - 2021/01/11
|
22
45
|
|
23
46
|
* Upgrade all dependencies.
|
24
47
|
|
@@ -26,18 +49,18 @@
|
|
26
49
|
|
27
50
|
* Fix code and build under Ruby 3.0.
|
28
51
|
|
29
|
-
|
52
|
+
## 0.9.1 - 2020/12/24
|
30
53
|
|
31
54
|
* Fixes a bug where proxy types are not properly resolved when used
|
32
55
|
in a heading extra, e.g. `{ ...: Proxy }`
|
33
56
|
|
34
|
-
|
57
|
+
## 0.9.0 - 2020/12/16
|
35
58
|
|
36
59
|
* Add Type#to_json_schema that converts Finitio types to JSON schema
|
37
60
|
representations. This first implementation skips all constraints on sub types,
|
38
61
|
though. You need to explicitly require 'finitio/json_schema' to use it.
|
39
62
|
|
40
|
-
|
63
|
+
## 0.8.0 - 2019/10/21
|
41
64
|
|
42
65
|
* Add `Type#unconstrained` that returns a super type with all user specific
|
43
66
|
constraints removed on sub types, recursively on all non scalar types.
|
@@ -47,7 +70,7 @@
|
|
47
70
|
* Add support for random data generation through `Finitio::Generation`.
|
48
71
|
Please `require 'finitio/generation'` to use it.
|
49
72
|
|
50
|
-
|
73
|
+
## 0.7.0 / 2019-02-28
|
51
74
|
|
52
75
|
* Implement (basic) @import feature, working with relative paths
|
53
76
|
and a standard library. The standard library systems are memoized
|
@@ -60,28 +83,28 @@
|
|
60
83
|
* WARN: Finitio::DEFAULT_SYSTEM is deprecated. Use @import
|
61
84
|
finitio/data instead.
|
62
85
|
|
63
|
-
|
86
|
+
## 0.6.1 / 2018-03-23
|
64
87
|
|
65
88
|
* Fix support for typed extra attributes, a KeyError was raised when
|
66
89
|
keys were Symbols and not Strings.
|
67
90
|
|
68
|
-
|
91
|
+
## 0.6.0 / 2018-02-17
|
69
92
|
|
70
93
|
* Add support for typed extra attributes, e.g. { ...: Integer }
|
71
94
|
|
72
|
-
|
95
|
+
## 0.5.2 / 2017-01-08
|
73
96
|
|
74
97
|
* Disable memoization in parser because it leads to terrible performance
|
75
98
|
issues on some schemas.
|
76
99
|
* Avoid alternatives on high-level rules (Union, SubType) to prevent many
|
77
100
|
fallbacks that kill performance without memoization enabled.
|
78
101
|
|
79
|
-
|
102
|
+
## 0.5.1 / 2015-09-22
|
80
103
|
|
81
104
|
* Enabled memoization in parser to avoid very long parsing time on complex
|
82
105
|
schemas.
|
83
106
|
|
84
|
-
|
107
|
+
## 0.5.0 / 2015-09-18
|
85
108
|
|
86
109
|
* Breaking changes on public API
|
87
110
|
|
@@ -147,29 +170,29 @@
|
|
147
170
|
* Make Finitio compatible with both Citrus 2.4.x and Citrus 3.x
|
148
171
|
* Fixed parsing of constraint expressions having inner parentheses
|
149
172
|
|
150
|
-
|
173
|
+
## 0.4.1 / 2014-03-20
|
151
174
|
|
152
175
|
* Fixed access to the default system that lead to 'Unknown system
|
153
176
|
Finitio/default (Finitio::Error)'
|
154
177
|
|
155
|
-
|
178
|
+
## 0.4.0 / 2014-03-20
|
156
179
|
|
157
180
|
* Finitio(-rb) is born from the sources of Q(rb) 0.3.0
|
158
181
|
* Finitio.parse now recognizes Path-like objects (responding to :to_path),
|
159
182
|
allowing to parse files directly (through Pathname, Path, etc.).
|
160
183
|
|
161
|
-
|
184
|
+
## 0.3.0 / 2014-03-09
|
162
185
|
|
163
186
|
* Added AnyType abstraction, aka '.'
|
164
187
|
* Added support for external contracts in ADTs
|
165
188
|
* Added support for extracting an Abstract Syntax Tree from parsing result
|
166
189
|
* Allows camelCasing in constraint names
|
167
190
|
|
168
|
-
|
191
|
+
## 0.2.0 / 2014-03-04
|
169
192
|
|
170
193
|
* Fix dependencies in gemspec (judofyr)
|
171
194
|
|
172
|
-
|
195
|
+
## 0.1.0 / 2014-03-03
|
173
196
|
|
174
197
|
* Enhancements
|
175
198
|
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
finitio (0.
|
4
|
+
finitio (0.12.0)
|
5
5
|
citrus (>= 3.0, < 4.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (
|
10
|
+
activesupport (7.0.4.3)
|
11
11
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
|
-
i18n (>=
|
13
|
-
minitest (
|
14
|
-
tzinfo (~>
|
12
|
+
i18n (>= 1.6, < 2)
|
13
|
+
minitest (>= 5.1)
|
14
|
+
tzinfo (~> 2.0)
|
15
15
|
awesome_print (1.9.2)
|
16
16
|
builder (3.2.4)
|
17
17
|
citrus (3.0.2)
|
18
|
-
concurrent-ruby (1.
|
18
|
+
concurrent-ruby (1.2.2)
|
19
19
|
coveralls (0.8.23)
|
20
20
|
json (>= 1.8, < 3)
|
21
21
|
simplecov (~> 0.16.1)
|
@@ -54,16 +54,16 @@ GEM
|
|
54
54
|
cucumber-cucumber-expressions (~> 10.1, >= 10.1.0)
|
55
55
|
cucumber-messages (~> 12.2, >= 12.2.0)
|
56
56
|
diff-lcs (1.3)
|
57
|
-
docile (1.
|
57
|
+
docile (1.4.0)
|
58
58
|
ffi (1.15.5)
|
59
|
-
i18n (1.
|
59
|
+
i18n (1.13.0)
|
60
60
|
concurrent-ruby (~> 1.0)
|
61
61
|
json (2.6.3)
|
62
62
|
middleware (0.1.0)
|
63
|
-
minitest (5.
|
63
|
+
minitest (5.18.0)
|
64
64
|
multi_json (1.15.0)
|
65
65
|
multi_test (0.1.2)
|
66
|
-
path (2.0
|
66
|
+
path (2.1.0)
|
67
67
|
protobuf-cucumber (3.10.8)
|
68
68
|
activesupport (>= 3.2)
|
69
69
|
middleware
|
@@ -74,12 +74,12 @@ GEM
|
|
74
74
|
rspec-core (~> 3.12.0)
|
75
75
|
rspec-expectations (~> 3.12.0)
|
76
76
|
rspec-mocks (~> 3.12.0)
|
77
|
-
rspec-core (3.12.
|
77
|
+
rspec-core (3.12.2)
|
78
78
|
rspec-support (~> 3.12.0)
|
79
|
-
rspec-expectations (3.12.
|
79
|
+
rspec-expectations (3.12.3)
|
80
80
|
diff-lcs (>= 1.2.0, < 2.0)
|
81
81
|
rspec-support (~> 3.12.0)
|
82
|
-
rspec-mocks (3.12.
|
82
|
+
rspec-mocks (3.12.5)
|
83
83
|
diff-lcs (>= 1.2.0, < 2.0)
|
84
84
|
rspec-support (~> 3.12.0)
|
85
85
|
rspec-support (3.12.0)
|
@@ -89,16 +89,16 @@ GEM
|
|
89
89
|
simplecov-html (~> 0.10.0)
|
90
90
|
simplecov-html (0.10.2)
|
91
91
|
sync (0.5.0)
|
92
|
-
sys-uname (1.2.
|
92
|
+
sys-uname (1.2.3)
|
93
93
|
ffi (~> 1.1)
|
94
94
|
term-ansicolor (1.7.1)
|
95
95
|
tins (~> 1.0)
|
96
|
-
thor (1.2.
|
96
|
+
thor (1.2.2)
|
97
97
|
thread_safe (0.3.6)
|
98
98
|
tins (1.32.1)
|
99
99
|
sync
|
100
|
-
tzinfo (
|
101
|
-
|
100
|
+
tzinfo (2.0.6)
|
101
|
+
concurrent-ruby (~> 1.0)
|
102
102
|
|
103
103
|
PLATFORMS
|
104
104
|
x86_64-linux
|
@@ -109,7 +109,7 @@ DEPENDENCIES
|
|
109
109
|
cucumber (~> 4.1)
|
110
110
|
finitio!
|
111
111
|
multi_json (~> 1.15)
|
112
|
-
path (>= 2.
|
112
|
+
path (>= 2.1, < 3.0)
|
113
113
|
rake (~> 13.0)
|
114
114
|
rspec (~> 3.0)
|
115
115
|
|
data/finitio.gemspec
CHANGED
@@ -19,13 +19,13 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.test_files = Dir["test/**/*"] + Dir["spec/**/*"]
|
20
20
|
s.bindir = "bin"
|
21
21
|
s.executables = (Dir["bin/*"]).collect{|f| File.basename(f)}
|
22
|
-
|
22
|
+
|
23
23
|
s.add_dependency("citrus", ">= 3.0", "< 4.0")
|
24
|
-
|
24
|
+
|
25
25
|
s.add_development_dependency("rake", "~> 13.0")
|
26
26
|
s.add_development_dependency("rspec", "~> 3.0")
|
27
27
|
s.add_development_dependency("cucumber", "~> 4.1")
|
28
|
-
s.add_development_dependency("path", ">= 2.
|
28
|
+
s.add_development_dependency("path", ">= 2.1", "< 3.0")
|
29
29
|
s.add_development_dependency("awesome_print", "~> 1.8")
|
30
30
|
s.add_development_dependency("coveralls", "~> 0.8")
|
31
31
|
s.add_development_dependency("multi_json", "~> 1.15")
|
data/lib/finitio/generation.rb
CHANGED
@@ -7,7 +7,7 @@ module Finitio
|
|
7
7
|
}
|
8
8
|
unless heading.empty?
|
9
9
|
base[:properties] = heading.inject({}){|ps,a|
|
10
|
-
|
10
|
+
ps.merge(a.name => a.type.to_json_schema(*args, &bl))
|
11
11
|
}
|
12
12
|
end
|
13
13
|
unless (reqs = heading.select{|a| a.required? }).empty?
|
@@ -2,11 +2,10 @@ module Finitio
|
|
2
2
|
class ProxyType
|
3
3
|
|
4
4
|
def to_json_schema(*args, &bl)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
5
|
+
# ProxyType is supposed to be used only for recursive types.
|
6
|
+
# We don't have support for references yet, so let just
|
7
|
+
# generate an object here in the mean time.
|
8
|
+
{ type: "object" }
|
10
9
|
end
|
11
10
|
|
12
11
|
end # module ProxyType
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Finitio
|
2
|
+
# Part of the compilation schema, this proxy resolver replaces
|
3
|
+
# proxies by their real Type instance.
|
4
|
+
#
|
5
|
+
# Given that Finitio can support recursive types, we do this in
|
6
|
+
# two passes:
|
7
|
+
# 1. Replace proxy types by rewrite (see Type#resolve_proxies)
|
8
|
+
# in a depth first search.
|
9
|
+
# 2. If a loop is found, recreate a late ProxyType, that is then
|
10
|
+
# bound later by mutation.
|
11
|
+
#
|
12
|
+
# So ProxyType may still be present in the type chain, but will
|
13
|
+
# only correspond to recursive types.
|
14
|
+
class ProxyResolver
|
15
|
+
def resolve!(system)
|
16
|
+
@system = system
|
17
|
+
@built = {}
|
18
|
+
@building = {}
|
19
|
+
@late_proxies = []
|
20
|
+
system.types.each_key do |name|
|
21
|
+
fetch(name)
|
22
|
+
end
|
23
|
+
@late_proxies.each do |proxy|
|
24
|
+
proxy.bind!(self)
|
25
|
+
end
|
26
|
+
system.dup(@built)
|
27
|
+
end
|
28
|
+
|
29
|
+
def fetch(name, &bl)
|
30
|
+
@built[name] || build_it(name) || import_it(name, &bl)
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_it(name)
|
34
|
+
if under_build = @building[name]
|
35
|
+
proxy = ProxyType.new(name)
|
36
|
+
@late_proxies << proxy
|
37
|
+
proxy
|
38
|
+
else
|
39
|
+
return nil unless type = @system.fetch(name, false){ nil }
|
40
|
+
|
41
|
+
@building[name] = type
|
42
|
+
@built[name] = type.resolve_proxies(self)
|
43
|
+
@building[name] = nil
|
44
|
+
@built[name]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def import_it(name, &bl)
|
49
|
+
@system.fetch_on_imports(name, &bl)
|
50
|
+
end
|
51
|
+
end # class ProxyResolver
|
52
|
+
end # module Finitio
|
data/lib/finitio/support.rb
CHANGED
data/lib/finitio/syntax.rb
CHANGED
@@ -21,18 +21,18 @@ module Finitio
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.ast(source)
|
24
|
-
parse(source, root:
|
24
|
+
parse(source, root: 'system').to_ast
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.compile(source, cpl = nil)
|
28
28
|
cpl = Compilation.coerce(cpl, source)
|
29
|
-
parse(source, root:
|
30
|
-
cpl.
|
29
|
+
parse(source, root: 'system').compile(cpl)
|
30
|
+
ProxyResolver.new.resolve!(cpl.system)
|
31
31
|
end
|
32
32
|
|
33
33
|
def self.compile_type(source, cpl = nil)
|
34
34
|
cpl = Compilation.coerce(cpl, source)
|
35
|
-
parse(source, root:
|
35
|
+
parse(source, root: 'type').compile(cpl)
|
36
36
|
end
|
37
37
|
|
38
38
|
end # module Syntax
|
data/lib/finitio/system.rb
CHANGED
@@ -50,24 +50,23 @@ module Finitio
|
|
50
50
|
def fetch(name, with_imports = true, &bl)
|
51
51
|
if with_imports
|
52
52
|
@types.fetch(name) do
|
53
|
-
|
53
|
+
fetch_on_imports(name, &bl)
|
54
54
|
end
|
55
55
|
else
|
56
56
|
@types.fetch(name, &bl)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
60
|
+
def fetch_on_imports(name, imports = @imports, &bl)
|
61
61
|
if imports.empty?
|
62
62
|
raise KeyError, %Q{key not found: "#{name}"} unless bl
|
63
63
|
bl.call(name)
|
64
64
|
else
|
65
65
|
imports.first.fetch(name, false) do
|
66
|
-
|
66
|
+
fetch_on_imports(name, imports[1..-1], &bl)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
70
|
-
private :_fetch
|
71
70
|
|
72
71
|
def factory
|
73
72
|
@factory ||= TypeFactory.new
|
@@ -89,22 +88,12 @@ module Finitio
|
|
89
88
|
Syntax.compile(source, self.dup)
|
90
89
|
end
|
91
90
|
|
92
|
-
def resolve_proxies(recurse = true)
|
93
|
-
rebuilt = {}
|
94
|
-
scope = FetchScope.new(self, rebuilt)
|
95
|
-
types.each_with_object(rebuilt) do |(name,type),memo|
|
96
|
-
rebuilt[name] = type.resolve_proxies(scope)
|
97
|
-
end
|
98
|
-
resolved = System.new(rebuilt, imports)
|
99
|
-
recurse ? resolved.resolve_proxies(false) : resolved
|
100
|
-
end
|
101
|
-
|
102
91
|
def inspect
|
103
92
|
@types.each_pair.map{|k,v| "#{k} = #{v}" }.join("\n")
|
104
93
|
end
|
105
94
|
|
106
|
-
def dup
|
107
|
-
System.new(
|
95
|
+
def dup(types = @types.dup, imports = @imports.dup)
|
96
|
+
System.new(types, imports)
|
108
97
|
end
|
109
98
|
|
110
99
|
def check_and_warn(logger = nil)
|
data/lib/finitio/type/ad_type.rb
CHANGED
@@ -30,7 +30,7 @@ module Finitio
|
|
30
30
|
# rgb_infotype = TupleType.new(...)
|
31
31
|
#
|
32
32
|
# # The RGB contract converter, an object that responds to `call` to
|
33
|
-
# # convert from a valid Hash[r:
|
33
|
+
# # convert from a valid Hash[r: Integer, ...] to a ColorImpl instance.
|
34
34
|
# rgb_contract = ...
|
35
35
|
#
|
36
36
|
# AdType.new(ColorImpl, rgb: [rgb_infotype, rgb_contract], hex: ...)
|
@@ -3,21 +3,21 @@ module Finitio
|
|
3
3
|
# A BuiltinType generator allows capuring an information type to a type of
|
4
4
|
# the host language, here a Ruby class. For instance,
|
5
5
|
#
|
6
|
-
# Int := BuiltinType(ruby.
|
6
|
+
# Int := BuiltinType(ruby.Integer)
|
7
7
|
#
|
8
8
|
# The set of values captured by the information type is the same set of
|
9
9
|
# values that can be represented by the host type. In the example, `Int`
|
10
|
-
# captures the same set of numbers as ruby's
|
10
|
+
# captures the same set of numbers as ruby's Integer.
|
11
11
|
#
|
12
12
|
# The ruby class is used as concrete representation of the information type.
|
13
13
|
# In the example:
|
14
14
|
#
|
15
|
-
# R(Int) =
|
15
|
+
# R(Int) = Integer
|
16
16
|
#
|
17
17
|
# Accordingly, the `dress` transformation function has the following signature:
|
18
18
|
#
|
19
19
|
# dress :: Alpha -> Int throws TypeError
|
20
|
-
# dress :: Object ->
|
20
|
+
# dress :: Object -> Integer throws TypeError
|
21
21
|
#
|
22
22
|
class BuiltinType < Type
|
23
23
|
|
@@ -28,7 +28,9 @@ module Finitio
|
|
28
28
|
|
29
29
|
def instantiate(compilation, sub_types)
|
30
30
|
overrides = Hash[vars.zip(sub_types)]
|
31
|
-
defn.resolve_proxies(compilation.with_scope(overrides))
|
31
|
+
defn.resolve_proxies(compilation.with_scope(overrides)).dup.tap{|x|
|
32
|
+
x.send(:name=, "#{name}<#{overrides.values.join(',')}>", true)
|
33
|
+
}
|
32
34
|
end
|
33
35
|
|
34
36
|
def unconstrained
|
@@ -15,8 +15,26 @@ module Finitio
|
|
15
15
|
"_#{target_name}_"
|
16
16
|
end
|
17
17
|
|
18
|
+
def include?(*args, &bl)
|
19
|
+
raise Error, "Proxy not resolved: #{target_name}" unless @target
|
20
|
+
|
21
|
+
@target.include?(*args, &bl)
|
22
|
+
end
|
23
|
+
|
24
|
+
def dress(*args, &bl)
|
25
|
+
raise Error, "Proxy not resolved: #{target_name}" unless @target
|
26
|
+
|
27
|
+
@target.dress(*args, &bl)
|
28
|
+
end
|
29
|
+
|
30
|
+
def bind!(system)
|
31
|
+
@target = system.fetch(target_name) {
|
32
|
+
raise Error, "No such type `#{target_name}` in #{system}"
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
18
36
|
def resolve_proxies(system)
|
19
|
-
system.fetch(target_name){
|
37
|
+
system.fetch(target_name) {
|
20
38
|
raise Error, "No such type `#{target_name}` in #{system}"
|
21
39
|
}
|
22
40
|
end
|
@@ -8,7 +8,7 @@ module Finitio
|
|
8
8
|
#
|
9
9
|
# This class allows capturing those information types, as in:
|
10
10
|
#
|
11
|
-
# Length = BuiltinType.new(
|
11
|
+
# Length = BuiltinType.new(Integer)
|
12
12
|
# Angle = BuiltinType.new(Float)
|
13
13
|
# Point = StructType.new([Length, Angle])
|
14
14
|
#
|
@@ -16,7 +16,7 @@ module Finitio
|
|
16
16
|
# values map to the concrete representations of each component type:
|
17
17
|
#
|
18
18
|
# R(Point) = Array[R(Length) ^ R(Angle)]
|
19
|
-
# = Array[
|
19
|
+
# = Array[Integer ^ Float]
|
20
20
|
# = Array[Numeric]
|
21
21
|
#
|
22
22
|
# where `^` denotes the `least common super type` operator on ruby classes.
|
@@ -18,12 +18,12 @@ module Finitio
|
|
18
18
|
# The concrete representation of the super type is kept as representation
|
19
19
|
# of the sub type. In other words:
|
20
20
|
#
|
21
|
-
# R(Byte) = R(Int) =
|
21
|
+
# R(Byte) = R(Int) = Integer
|
22
22
|
#
|
23
23
|
# Accordingly, the `dress` transformation function has the following signature:
|
24
24
|
#
|
25
25
|
# dress :: Alpha -> Byte throws TypeError
|
26
|
-
# dress :: Object ->
|
26
|
+
# dress :: Object -> Integer throws TypeError
|
27
27
|
#
|
28
28
|
class SubType < Type
|
29
29
|
|
@@ -7,7 +7,7 @@ module Finitio
|
|
7
7
|
#
|
8
8
|
# This class allows capturing those information types, as in:
|
9
9
|
#
|
10
|
-
# Length = BuiltinType.new(
|
10
|
+
# Length = BuiltinType.new(Integer)
|
11
11
|
# Angle = BuiltinType.new(Float)
|
12
12
|
# Point = TupleType.new(Heading.new([
|
13
13
|
# Attribute.new(:r, Length),
|
@@ -19,7 +19,7 @@ module Finitio
|
|
19
19
|
# type:
|
20
20
|
#
|
21
21
|
# R(Point) = Hash[r: R(Length), theta: R(Angle)]
|
22
|
-
# = Hash[r:
|
22
|
+
# = Hash[r: Integer, theta: Float]
|
23
23
|
#
|
24
24
|
# Accordingly, the `dress` transformation function has the signature below.
|
25
25
|
# It expects it's Alpha/Object argument to be a Hash with all and only the
|
@@ -27,7 +27,7 @@ module Finitio
|
|
27
27
|
# applies on every attribute value according to their respective type.
|
28
28
|
#
|
29
29
|
# dress :: Alpha -> Point throws TypeError
|
30
|
-
# dress :: Object -> Hash[r:
|
30
|
+
# dress :: Object -> Hash[r: Integer, theta: Float] throws TypeError
|
31
31
|
#
|
32
32
|
class TupleType < Type
|
33
33
|
include HeadingBasedType
|
@@ -8,7 +8,7 @@ module Finitio
|
|
8
8
|
#
|
9
9
|
# This class allows capturing such union types, as follows:
|
10
10
|
#
|
11
|
-
# Int = BuiltinType.new(
|
11
|
+
# Int = BuiltinType.new(Integer)
|
12
12
|
# Real = BuiltinType.new(Float)
|
13
13
|
# Numeric = UnionType.new([ Int, Real ])
|
14
14
|
#
|
@@ -17,7 +17,7 @@ module Finitio
|
|
17
17
|
# value ends the process and the value is simply returned. Accordingly,
|
18
18
|
# the concrete representation will be
|
19
19
|
#
|
20
|
-
# R(Numeric) = R(Int) ^ R(Real) =
|
20
|
+
# R(Numeric) = R(Int) ^ R(Real) = Integer ^ Float = Numeric
|
21
21
|
#
|
22
22
|
# where `^` denotes the `least common super type` operator on ruby classes.
|
23
23
|
#
|
data/lib/finitio/type.rb
CHANGED
@@ -32,8 +32,10 @@ module Finitio
|
|
32
32
|
@name || default_name
|
33
33
|
end
|
34
34
|
|
35
|
-
def name=(n)
|
36
|
-
|
35
|
+
def name=(n, force = false)
|
36
|
+
if !@name.nil? && !force
|
37
|
+
raise Error, "Name already set to `#{@name}` on #{self.class}"
|
38
|
+
end
|
37
39
|
@name = n
|
38
40
|
end
|
39
41
|
|