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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 16614a276ddf1553d4373e5da9ab78d7f03f2fc8cadec6190c28bb27bdd95b99
4
- data.tar.gz: 98903f6ec0c9e010fd429f6b1753b34f52b4cfc67c7eafd21b1103c6ac429bba
3
+ metadata.gz: c8eae41b5b093b55c02a81bbe81b08202eb4ecd64c1dd288246c0cd4af44c627
4
+ data.tar.gz: 208158a80e89e789d74c66f295ee4cbec6d37e6d9f3185dedfbcaa30a156fe35
5
5
  SHA512:
6
- metadata.gz: 8278546ef246d8f4d5db72b18d5c91dfa3dc1d7f18f81b7491ca01df38a64495a3b5eb26df0fa18b652f59d56784efb8fe9348b5b65d091aa27a09e6b8f144a4
7
- data.tar.gz: deaa7b43f225788b9366610572f5994eec8950a8e66c8159b83a18b874139d322270f274c4753dc28b6926b7c295d42a2f77600211dfbd0df0e24b82e1a155b5
6
+ metadata.gz: dc1393417a3cdb013fdbcc085dcb3ba7dda45784e73a26ef44c1ee21b4322a9a18063d16c0cae7d3266be829ce31c6090773ba1631712211c388d84b21e0161d
7
+ data.tar.gz: 2f07cb2e882fbff31b73eee169a99849729b8f4136888335b2915a183ff32ed8aa78a66d93ea7765f0b09f0747b4b09cfae2aece5ca7478f41892b173a0ce2ab
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.1.05] - 2021-03-05
2
+ - Test for Fibbonacci recursive function is now passing.
3
+
4
+ ### Fixed
5
+ - Method `BackEnd::Function#call` a call doesn't no more generate of TWO scopes
6
+
1
7
  ## [0.1.04] - 2021-02-28
2
8
 
3
9
  ### Added
@@ -200,18 +200,7 @@ module Loxxy
200
200
  when NativeFunction
201
201
  stack.push callee.call # Pass arguments
202
202
  when Function
203
- new_env = Environment.new(symbol_table.current_env)
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
- body.empty? ? Datatype::Nil.instance : body.accept(aVisitor)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Loxxy
4
- VERSION = '0.1.04'
4
+ VERSION = '0.1.05'
5
5
  end
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.04
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-02-28 00:00:00.000000000 Z
11
+ date: 2021-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rley