koi-vm 0.0.2 → 0.0.3

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/koi-vm.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{koi-vm}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Gough"]
12
- s.date = %q{2010-08-25}
12
+ s.date = %q{2010-08-27}
13
13
  s.description = %q{A prototype Virtual Machine written in Ruby. Why would anyone write such a thing? Because it's fun, and it's a great learning tool.}
14
14
  s.email = %q{aaron@aarongough.com}
15
15
  s.extra_rdoc_files = [
@@ -5,8 +5,12 @@ module KoiVM
5
5
  vm.data_stack.push([FUNCTION_, vm.instruction_pointer + 2])
6
6
  function_id = vm.opcodes[vm.instruction_pointer + 1]
7
7
  while(true)
8
- vm.instruction_pointer = vm.opcodes.slice(vm.instruction_pointer, vm.opcodes.length).index(END_FUNCTION)
9
- break if(vm.opcodes.slice(vm.instruction_pointer, 4) == [END_FUNCTION, 0, END_FUNCTION, function_id])
8
+ vm.instruction_pointer = vm.opcodes.slice(vm.instruction_pointer, vm.opcodes.length).index(END_FUNCTION) + vm.instruction_pointer
9
+ if(vm.opcodes.slice(vm.instruction_pointer, 4) == [END_FUNCTION, 0, END_FUNCTION, function_id])
10
+ break
11
+ else
12
+ vm.instruction_pointer = vm.instruction_pointer + 1
13
+ end
10
14
  end
11
15
  vm.instruction_pointer = vm.instruction_pointer + 4
12
16
  end
@@ -10,12 +10,32 @@ class PushFunctionTest < Test::Unit::TestCase
10
10
  PUSH_FUNCTION, 1,
11
11
  NO_OP,
12
12
  NO_OP,
13
+ RETURN,
13
14
  END_FUNCTION, 0,
14
15
  END_FUNCTION, 1
15
16
  ]
16
17
  assert_equal [[FUNCTION_, 2]], vm.data_stack
17
- assert_equal 8, vm.instruction_pointer
18
+ assert_equal 9, vm.instruction_pointer
19
+ end
20
+
21
+ test "should push function reference onto stack that contains nested function definition" do
22
+ vm = VM.new
23
+ vm.run [
24
+ PUSH_FUNCTION, 6,
25
+ NO_OP,
26
+ PUSH_FUNCTION, 2,
27
+ NO_OP,
28
+ RETURN,
29
+ END_FUNCTION, 0,
30
+ END_FUNCTION, 2,
31
+ NO_OP,
32
+ RETURN,
33
+ END_FUNCTION, 0,
34
+ END_FUNCTION, 6
35
+ ]
36
+ assert_equal [[FUNCTION_, 2]], vm.data_stack
37
+ assert_equal 17, vm.instruction_pointer
18
38
  end
19
-
20
39
 
40
+
21
41
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Gough
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-25 00:00:00 -04:00
17
+ date: 2010-08-27 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20