loxxy 0.1.04 → 0.1.05
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/loxxy/back_end/engine.rb +1 -12
- data/lib/loxxy/back_end/function.rb +16 -3
- data/lib/loxxy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c8eae41b5b093b55c02a81bbe81b08202eb4ecd64c1dd288246c0cd4af44c627
|
4
|
+
data.tar.gz: 208158a80e89e789d74c66f295ee4cbec6d37e6d9f3185dedfbcaa30a156fe35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc1393417a3cdb013fdbcc085dcb3ba7dda45784e73a26ef44c1ee21b4322a9a18063d16c0cae7d3266be829ce31c6090773ba1631712211c388d84b21e0161d
|
7
|
+
data.tar.gz: 2f07cb2e882fbff31b73eee169a99849729b8f4136888335b2915a183ff32ed8aa78a66d93ea7765f0b09f0747b4b09cfae2aece5ca7478f41892b173a0ce2ab
|
data/CHANGELOG.md
CHANGED
@@ -200,18 +200,7 @@ module Loxxy
|
|
200
200
|
when NativeFunction
|
201
201
|
stack.push callee.call # Pass arguments
|
202
202
|
when Function
|
203
|
-
|
204
|
-
symbol_table.enter_environment(new_env)
|
205
|
-
callee.parameters&.each do |param_name|
|
206
|
-
local = Variable.new(param_name, stack.pop)
|
207
|
-
symbol_table.insert(local)
|
208
|
-
end
|
209
|
-
catch(:return) do
|
210
|
-
callee.call(aVisitor)
|
211
|
-
throw(:return)
|
212
|
-
end
|
213
|
-
|
214
|
-
symbol_table.leave_environment
|
203
|
+
callee.call(self, aVisitor)
|
215
204
|
else
|
216
205
|
raise Loxxy::RuntimeError, 'Can only call functions and classes.'
|
217
206
|
end
|
@@ -22,7 +22,7 @@ module Loxxy
|
|
22
22
|
def initialize(aName, parameterList, aBody, aStack)
|
23
23
|
@name = aName.dup
|
24
24
|
@parameters = parameterList
|
25
|
-
@body = aBody
|
25
|
+
@body = aBody.kind_of?(Ast::LoxNoopExpr) ? aBody : aBody.subnodes[0]
|
26
26
|
@stack = aStack
|
27
27
|
end
|
28
28
|
|
@@ -30,8 +30,21 @@ module Loxxy
|
|
30
30
|
stack.push self
|
31
31
|
end
|
32
32
|
|
33
|
-
def call(aVisitor)
|
34
|
-
|
33
|
+
def call(engine, aVisitor)
|
34
|
+
new_env = Environment.new(engine.symbol_table.current_env)
|
35
|
+
engine.symbol_table.enter_environment(new_env)
|
36
|
+
|
37
|
+
parameters&.each do |param_name|
|
38
|
+
local = Variable.new(param_name, stack.pop)
|
39
|
+
engine.symbol_table.insert(local)
|
40
|
+
end
|
41
|
+
|
42
|
+
catch(:return) do
|
43
|
+
(body.nil? || body.kind_of?(Ast::LoxNoopExpr)) ? Datatype::Nil.instance : body.accept(aVisitor)
|
44
|
+
throw(:return)
|
45
|
+
end
|
46
|
+
|
47
|
+
engine.symbol_table.leave_environment
|
35
48
|
end
|
36
49
|
|
37
50
|
# Logical negation.
|
data/lib/loxxy/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loxxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.05
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rley
|