rlang 0.4.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -3
- data/Gemfile.lock +4 -6
- data/README +11 -0
- data/README.md +18 -10
- data/bin/rlang +17 -5
- data/docs/RlangCompiler.md +5 -1
- data/docs/RlangManual.md +98 -20
- data/examples/fib/fib.rb +5 -1
- data/lib/builder/rlang/compiler.rb +2 -21
- data/lib/rlang/lib/array/array32.rb +59 -0
- data/lib/rlang/lib/array/array64.rb +56 -0
- data/lib/rlang/lib/array.rb +6 -0
- data/lib/rlang/lib/base64.rb +223 -0
- data/lib/rlang/lib/io.rb +75 -0
- data/lib/rlang/lib/kernel.rb +23 -0
- data/lib/rlang/lib/malloc.rb +12 -8
- data/lib/rlang/lib/memory.rb +102 -2
- data/lib/rlang/lib/object.rb +40 -4
- data/lib/rlang/lib/rlang.rb +29 -0
- data/lib/rlang/lib/rlang_core.rb +15 -0
- data/lib/rlang/lib/string.rb +106 -8
- data/lib/rlang/lib/type/i32.rb +43 -0
- data/lib/rlang/lib/type/i64.rb +2 -0
- data/lib/rlang/lib/unistd.rb +1 -2
- data/lib/rlang/lib/wasi.rb +184 -0
- data/lib/rlang/parser/attr.rb +9 -13
- data/lib/rlang/parser/const.rb +105 -1
- data/lib/rlang/parser/cvar.rb +11 -7
- data/lib/rlang/parser/data.rb +17 -6
- data/lib/rlang/parser/export.rb +4 -3
- data/lib/rlang/parser/ext/integer.rb +3 -1
- data/lib/rlang/parser/ext/type.rb +30 -1
- data/lib/rlang/parser/global.rb +10 -2
- data/lib/rlang/parser/ivar.rb +3 -7
- data/lib/rlang/parser/klass.rb +8 -35
- data/lib/rlang/parser/method.rb +36 -12
- data/lib/rlang/parser/module.rb +143 -0
- data/lib/rlang/parser/wgenerator.rb +462 -168
- data/lib/rlang/parser/wnode.rb +387 -142
- data/lib/rlang/parser/wtype.rb +30 -7
- data/lib/rlang/parser.rb +506 -231
- data/lib/rlang/version.rb +1 -1
- data/lib/rlang.rb +3 -0
- data/lib/ruby/mirror/rstring.rb +16 -0
- data/lib/utils/exceptions.rb +12 -0
- data/rlang.gemspec +4 -4
- metadata +25 -13
- data/lib/rlang/lib.rb +0 -11
data/lib/rlang/parser/wtype.rb
CHANGED
@@ -18,17 +18,18 @@ class WType
|
|
18
18
|
include Log
|
19
19
|
|
20
20
|
WASM_TYPE_MAP = {
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
UI64: Type::UI64,
|
22
|
+
I64: Type::I64,
|
23
|
+
UI32: Type::UI32,
|
24
|
+
I32: Type::I32,
|
25
|
+
F64: Type::F64,
|
26
|
+
F32: Type::F32
|
25
27
|
}
|
26
28
|
|
27
29
|
# Implicit Type cast order in decreasing order of precedence
|
28
30
|
# Class types have precedence over default integer type
|
29
31
|
# because of pointer arithmetics
|
30
|
-
|
31
|
-
CAST_PRECEDENCE = [:F64, :F32, :I64, :Class, :I32]
|
32
|
+
CAST_PRECEDENCE = [:F64, :F32, :UI64, :I64, :Class, :UI32, :I32]
|
32
33
|
|
33
34
|
attr_reader :name
|
34
35
|
|
@@ -45,11 +46,28 @@ class WType
|
|
45
46
|
wtypes[leading_idx]
|
46
47
|
end
|
47
48
|
|
49
|
+
# Name is a symbol of the form :A or :"A::B" or :"A::B::C"
|
50
|
+
# or a string "A" or "A::B" or "A::B::C"
|
51
|
+
# or it can also be an array of symbols [:A], [:A, :B] or [:A, :B, :C]
|
52
|
+
# (It is not a class object)
|
48
53
|
def initialize(name)
|
49
|
-
|
54
|
+
if name.is_a? Symbol
|
55
|
+
@name = name
|
56
|
+
elsif name.is_a? String
|
57
|
+
@name = name.to_sym
|
58
|
+
elsif name.is_a? Array
|
59
|
+
@name = name.map(&:to_s).join('::').to_sym
|
60
|
+
else
|
61
|
+
raise "Unknown type for WType name (got #{name}, class: #{name.class}"
|
62
|
+
end
|
50
63
|
raise "Invalid WType #{name.inspect}" unless self.valid?
|
51
64
|
end
|
52
65
|
|
66
|
+
def class_path
|
67
|
+
return [] if self.blank?
|
68
|
+
name.to_s.split('::').map(&:to_sym)
|
69
|
+
end
|
70
|
+
|
53
71
|
def default?
|
54
72
|
@name == WType::DEFAULT.name
|
55
73
|
end
|
@@ -62,6 +80,10 @@ class WType
|
|
62
80
|
WASM_TYPE_MAP.has_key? @name
|
63
81
|
end
|
64
82
|
|
83
|
+
def signed?
|
84
|
+
self.native? && WASM_TYPE_MAP[@name].signed?
|
85
|
+
end
|
86
|
+
|
65
87
|
def blank?
|
66
88
|
@name == :none || @name == :nil
|
67
89
|
end
|
@@ -111,6 +133,7 @@ class WType
|
|
111
133
|
end
|
112
134
|
|
113
135
|
DEFAULT = self.new(WASM_TYPE_MAP.key(Type::DEFAULT))
|
136
|
+
UNSIGNED_DEFAULT = self.new(WASM_TYPE_MAP.key(Type::UNSIGNED_DEFAULT))
|
114
137
|
|
115
138
|
end
|
116
139
|
|