typeprof 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/typeprof/config.rb +10 -6
- data/lib/typeprof/import.rb +26 -12
- data/lib/typeprof/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce8f2e03762e154e1910d079911b6414813bde3471af4a406bde5639eb06e8b5
|
4
|
+
data.tar.gz: a47d0fd3ea250ed8e0d510b5d71630dd47816f35e65c49fd40b3085f22ad39ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9338387842c8ec612b3e400df4ee8a68506dad3702d53f6f31d4c02302f650b768452193095944a6465d2c843769e7b8b072ab53affb649b6d0ede8f7bae281
|
7
|
+
data.tar.gz: d2d0ae66c6294a63cde19661e59eebc9d3a0c7654c8967c597b39d9854fc0dcafa7fbd6cee0d80f669ad4bdad3c251795203d9bd07e45dbe55bc303c7deb2d05
|
data/Gemfile.lock
CHANGED
data/lib/typeprof/config.rb
CHANGED
@@ -69,19 +69,23 @@ module TypeProf
|
|
69
69
|
prologue_ep = ExecutionPoint.new(prologue_ctx, -1, nil)
|
70
70
|
prologue_env = Env.new(StaticEnv.new(:top, Type.nil, false), [], [], Utils::HashWrapper.new({}))
|
71
71
|
|
72
|
-
Config.rb_files.each do |
|
73
|
-
if
|
74
|
-
iseq = ISeq.compile_str(
|
72
|
+
Config.rb_files.each do |rb|
|
73
|
+
if rb.is_a?(Array) # [String name, String content]
|
74
|
+
iseq = ISeq.compile_str(*rb.reverse)
|
75
75
|
else
|
76
|
-
iseq = ISeq.compile(
|
76
|
+
iseq = ISeq.compile(rb)
|
77
77
|
end
|
78
78
|
ep, env = TypeProf.starting_state(iseq)
|
79
79
|
scratch.merge_env(ep, env)
|
80
80
|
scratch.add_callsite!(ep.ctx, prologue_ep, prologue_env) {|ty, ep| }
|
81
81
|
end
|
82
82
|
|
83
|
-
Config.rbs_files.each do |
|
84
|
-
|
83
|
+
Config.rbs_files.each do |rbs|
|
84
|
+
if rbs.is_a?(Array) # [String name, String content]
|
85
|
+
Import.import_rbs_code(scratch, *rbs)
|
86
|
+
else
|
87
|
+
Import.import_rbs_file(scratch, rbs)
|
88
|
+
end
|
85
89
|
end
|
86
90
|
|
87
91
|
result = scratch.type_profile
|
data/lib/typeprof/import.rb
CHANGED
@@ -10,7 +10,10 @@ module TypeProf
|
|
10
10
|
def self.get_builtin_env
|
11
11
|
unless @builtin_env
|
12
12
|
@builtin_env = RBS::Environment.new
|
13
|
-
|
13
|
+
|
14
|
+
loader = RBS::EnvironmentLoader.new
|
15
|
+
new_decls = loader.load(env: @builtin_env).map {|decl,| decl }
|
16
|
+
@builtin_env_json = load_rbs(@builtin_env, new_decls)
|
14
17
|
end
|
15
18
|
|
16
19
|
return @builtin_env.dup, @builtin_env_json
|
@@ -21,27 +24,34 @@ module TypeProf
|
|
21
24
|
end
|
22
25
|
|
23
26
|
def load_library(lib)
|
24
|
-
|
27
|
+
loader = RBS::EnvironmentLoader.new(core_root: nil)
|
28
|
+
loader.add(library: lib)
|
29
|
+
new_decls = loader.load(env: @env).map {|decl,| decl }
|
30
|
+
RBSReader.load_rbs(@env, new_decls)
|
25
31
|
end
|
26
32
|
|
27
33
|
def load_path(path)
|
28
|
-
|
34
|
+
loader = RBS::EnvironmentLoader.new(core_root: nil)
|
35
|
+
loader.add(path: path)
|
36
|
+
new_decls = loader.load(env: @env).map {|decl,| decl }
|
37
|
+
RBSReader.load_rbs(@env, new_decls)
|
29
38
|
end
|
30
39
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
40
|
+
def load_rbs_string(name, content)
|
41
|
+
buffer = RBS::Buffer.new(name: name, content: content)
|
42
|
+
new_decls = []
|
43
|
+
RBS::Parser.parse_signature(buffer).each do |decl|
|
44
|
+
@env << decl
|
45
|
+
new_decls << decl
|
37
46
|
end
|
38
|
-
|
47
|
+
RBSReader.load_rbs(@env, new_decls)
|
48
|
+
end
|
39
49
|
|
50
|
+
def self.load_rbs(env, new_decls)
|
40
51
|
all_env = env.resolve_type_names
|
41
|
-
|
42
52
|
resolver = RBS::TypeNameResolver.from_env(all_env)
|
43
53
|
cur_env = RBS::Environment.new
|
44
|
-
new_decls.each do |decl
|
54
|
+
new_decls.each do |decl|
|
45
55
|
cur_env << env.resolve_declaration(resolver, decl, outer: [], prefix: RBS::Namespace.root)
|
46
56
|
end
|
47
57
|
|
@@ -445,6 +455,10 @@ module TypeProf
|
|
445
455
|
Import.new(scratch, scratch.rbs_reader.load_path(rbs_path)).import(true)
|
446
456
|
end
|
447
457
|
|
458
|
+
def self.import_rbs_code(scratch, rbs_name, rbs_code)
|
459
|
+
Import.new(scratch, scratch.rbs_reader.load_rbs_string(rbs_name, rbs_code)).import(true)
|
460
|
+
end
|
461
|
+
|
448
462
|
def initialize(scratch, json)
|
449
463
|
@scratch = scratch
|
450
464
|
@json = json
|
data/lib/typeprof/version.rb
CHANGED