rVM 0.0.14 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/README +4 -4
  2. data/bin/rvm +229 -0
  3. data/lib/rvm.rb +6 -6
  4. data/lib/rvm/acts_as_rvm_type.rb +26 -3
  5. data/lib/rvm/classes.rb +9 -15
  6. data/lib/rvm/classes/block.rb +8 -3
  7. data/lib/rvm/classes/class.rb +2 -2
  8. data/lib/rvm/classes/list.rb +1 -1
  9. data/lib/rvm/classes/null.rb +31 -0
  10. data/lib/rvm/classes/number.rb +4 -0
  11. data/lib/rvm/classes/object.rb +1 -1
  12. data/lib/rvm/classes/string.rb +6 -1
  13. data/lib/rvm/environment.rb +256 -0
  14. data/lib/rvm/functions.rb +9 -4
  15. data/lib/rvm/functions/array.rb +26 -2
  16. data/lib/rvm/functions/array/append.rb +31 -1
  17. data/lib/rvm/functions/array/at.rb +29 -1
  18. data/lib/rvm/functions/array/set_at.rb +29 -0
  19. data/lib/rvm/functions/association/assoc_get.rb +34 -0
  20. data/lib/rvm/functions/association/assoc_set.rb +32 -0
  21. data/lib/rvm/functions/bitwise.rb +3 -0
  22. data/lib/rvm/functions/bitwise/bitwise_and.rb +41 -0
  23. data/lib/rvm/functions/bitwise/bitwise_or.rb +41 -0
  24. data/lib/rvm/functions/bitwise/bitwise_xor.rb +41 -0
  25. data/lib/rvm/functions/collection/get.rb +37 -4
  26. data/lib/rvm/functions/collection/set.rb +37 -3
  27. data/lib/rvm/functions/collection/size.rb +33 -1
  28. data/lib/rvm/functions/general/cmp.rb +35 -7
  29. data/lib/rvm/functions/general/eq.rb +29 -0
  30. data/lib/rvm/functions/general/gt.rb +29 -0
  31. data/lib/rvm/functions/general/gte.rb +29 -0
  32. data/lib/rvm/functions/general/lt.rb +29 -0
  33. data/lib/rvm/functions/general/lte.rb +29 -0
  34. data/lib/rvm/functions/general/neq.rb +5 -0
  35. data/lib/rvm/functions/io/print.rb +38 -8
  36. data/lib/rvm/functions/list/align.rb +25 -1
  37. data/lib/rvm/functions/list/join.rb +27 -0
  38. data/lib/rvm/functions/list/map.rb +34 -0
  39. data/lib/rvm/functions/list/split.rb +31 -0
  40. data/lib/rvm/functions/logic/and.rb +36 -2
  41. data/lib/rvm/functions/logic/not.rb +27 -0
  42. data/lib/rvm/functions/logic/or.rb +32 -2
  43. data/lib/rvm/functions/math/add.rb +25 -0
  44. data/lib/rvm/functions/math/cos.rb +39 -0
  45. data/lib/rvm/functions/math/div.rb +25 -0
  46. data/lib/rvm/functions/math/mod.rb +41 -0
  47. data/lib/rvm/functions/math/mul.rb +25 -0
  48. data/lib/rvm/functions/math/neg.rb +25 -0
  49. data/lib/rvm/functions/math/power.rb +25 -0
  50. data/lib/rvm/functions/math/shl.rb +41 -0
  51. data/lib/rvm/functions/math/shr.rb +41 -0
  52. data/lib/rvm/functions/math/sin.rb +39 -0
  53. data/lib/rvm/functions/math/sub.rb +25 -0
  54. data/lib/rvm/functions/math/tan.rb +39 -0
  55. data/lib/rvm/functions/rails/print.rb +33 -3
  56. data/lib/rvm/interpreter.rb +405 -272
  57. data/lib/rvm/languages.rb +45 -11
  58. data/lib/rvm/languages/brainfuck.rb +15 -16
  59. data/lib/rvm/languages/ecma.rb +4 -1257
  60. data/lib/rvm/languages/ecma/compiler.rb +1353 -0
  61. data/lib/rvm/languages/ecma/core-math.js +84 -0
  62. data/lib/rvm/languages/math.rb +9 -16
  63. data/lib/rvm/languages/math/compiler.rb +9 -9
  64. data/lib/rvm/languages/math/tokenizer.rb +1 -1
  65. data/lib/rvm/languages/math/tree.rb +14 -14
  66. data/lib/rvm/library.rb +26 -18
  67. data/lib/rvm/optimisation.rb +109 -0
  68. data/lib/rvm/plugin.rb +109 -45
  69. data/lib/rvm/rails.rb +79 -54
  70. data/spec/classes/atom/association_spec.rb +8 -8
  71. data/spec/classes/atom/block_spec.rb +8 -5
  72. data/spec/classes/atom/boolean_spec.rb +1 -1
  73. data/spec/classes/atom/error_spec.rb +1 -1
  74. data/spec/classes/atom/list_spec.rb +1 -1
  75. data/spec/classes/atom/number_spec.rb +2 -2
  76. data/spec/classes/atom/string_spec.rb +1 -1
  77. data/spec/languages/ecma/ecma_spec.rb +94 -38
  78. data/spec/languages/ecma/json_spec.rb +4 -4
  79. data/spec/languages/math/compiler_spec.rb +5 -5
  80. data/spec/languages/math/tokenizer_spec.rb +1 -1
  81. data/spec/languages/math/tree_spec.rb +1 -1
  82. data/spec/{base → rvm}/class_spec.rb +2 -2
  83. data/spec/{base/interpreter → rvm}/enviroment_spec.rb +19 -9
  84. data/spec/{base → rvm}/function_spec.rb +2 -2
  85. data/spec/{functions → rvm/functions}/association/assoc_get_spec.rb +2 -2
  86. data/spec/{functions → rvm/functions}/association/assoc_set_spec.rb +2 -2
  87. data/spec/rvm/functions/collection/get_spec.rb +12 -0
  88. data/spec/rvm/functions/collection/set_spec.rb +10 -0
  89. data/spec/rvm/functions/collection/size_spec.rb +10 -0
  90. data/spec/{functions → rvm/functions}/list/split_spec.rb +3 -3
  91. data/spec/{functions → rvm/functions}/string/ansi_spec.rb +3 -3
  92. data/spec/{functions → rvm/functions}/string/capstr_spec.rb +3 -3
  93. data/spec/{functions → rvm/functions}/string/center_spec.rb +3 -3
  94. data/spec/{functions → rvm/functions}/string/ljust_spec.rb +3 -3
  95. data/spec/{functions → rvm/functions}/string/regmatch_spec.rb +3 -3
  96. data/spec/{functions → rvm/functions}/string/rjust_spec.rb +3 -3
  97. data/spec/{base → rvm}/interpreter/assignment_spec.rb +1 -1
  98. data/spec/rvm/interpreter/condition_spec.rb +103 -0
  99. data/spec/{base → rvm}/interpreter/constant_spec.rb +1 -1
  100. data/spec/rvm/interpreter/core_call_spec.rb +72 -0
  101. data/spec/{base → rvm}/interpreter/interpreter_spec.rb +1 -1
  102. data/spec/{base → rvm}/interpreter/parameter_spec.rb +1 -1
  103. data/spec/rvm/interpreter/sequence_spec.rb +47 -0
  104. data/spec/{base → rvm}/interpreter/variable_spec.rb +1 -1
  105. data/spec/{base → rvm}/plugin_spec.rb +2 -2
  106. metadata +66 -35
  107. data/lib/rake/helpers/code_statistics.rb +0 -167
  108. data/spec/base/interpreter/condition_spec.rb +0 -47
  109. data/spec/base/interpreter/function_call_spec.rb +0 -72
  110. data/spec/base/interpreter/sequence_spec.rb +0 -20
  111. data/spec/functions/collection/get_spec.rb +0 -12
  112. data/spec/functions/collection/set_spec.rb +0 -10
  113. data/spec/functions/collection/size_spec.rb +0 -10
data/README CHANGED
@@ -21,18 +21,18 @@ The following example implements a pretty easy calculator using the the math lan
21
21
  compiler = RVM::Languages[:math].new #Lets get us the compiler
22
22
  while s!= 'QUIT'
23
23
  s=gets.chomp
24
- puts compiler.compile(s).execute(RVM::Interpreter.env) # We pass an fresh enviroment as we don't need an environment.
24
+ puts compiler.compile(s).execute(compiler.env) # We pass an fresh environment as we don't need an environment.
25
25
  end
26
26
 
27
- Here one example that keeps set variables due to using one enviroment for all the calls.
27
+ Here one example that keeps set variables due to using one environment for all the calls.
28
28
 
29
29
  require 'rubygems'
30
30
  require 'rvm' # This loads the rVM gem
31
31
  require 'rvm/languages/math' #This loads the math plugin as well as the math function library
32
32
  s =''
33
33
  compiler = RVM::Languages[:math].new #Lets get us the compiler
34
- env = RVM::Interpreter.env
34
+ env = compiler.env
35
35
  while s!= 'QUIT'
36
36
  s=gets.chomp
37
- puts compiler.compile(s).execute(env) # We pass an fresh enviroment as we don't need an environment.
37
+ puts compiler.compile(s).execute(env) # We pass an fresh environment as we don't need an environment.
38
38
  end
data/bin/rvm ADDED
@@ -0,0 +1,229 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << "lib"
4
+ require 'optparse'
5
+ require 'ostruct'
6
+ require 'pp'
7
+ require 'rubygems'
8
+ require 'rvm'
9
+
10
+ rcfile = File.expand_path('~/.rvmrc')
11
+ if File.exist?(rcfile)
12
+ File.new(rcfile).each do |line|
13
+ line.chomp!
14
+ ARGV << line.gsub(/\s.*$/,'')
15
+ ARGV << line.gsub(/^.*?\s/,'')
16
+ end
17
+ end
18
+
19
+ class RVMOptParser
20
+ #
21
+ # Return a structure describing the options.
22
+ #
23
+ LANGUAGES = %w[ecma bf math]
24
+ LANGUAGES_ALIASES = { "js" => "ecma", "javascript" => "ecma" }
25
+ def self.parse(args)
26
+ # The options specified on the command line will be collected in *options*.
27
+ # We set default values here.
28
+ options = OpenStruct.new
29
+ options.library = []
30
+ options.rvm_library = []
31
+ options.core_library = []
32
+ options.verbose = false
33
+ options.language = :ecma
34
+ options.code = nil
35
+ options.use_default_core_libs = true
36
+
37
+ o = OptionParser.new do |opts|
38
+ opts.banner = "Usage: rvm [options]"
39
+
40
+ opts.separator ""
41
+ opts.separator "Specific options:"
42
+
43
+ # Mandatory argument.
44
+ opts.on("-r", "--require LIBRARY", "Require the LIBRARY before executing your script. This is for own libraries.") do |lib|
45
+ options.library << lib;
46
+ end
47
+
48
+ opts.on("-i", "--rvm-require RVM_LIBRARY", "Require the RVM_LIBRARY before executing your script. This is for rvm internal libraries.") do |lib|
49
+ options.rvm_library << "rvm/#{lib}"
50
+ end
51
+
52
+ opts.on("-b", "--no-corelibs", "Used to disable standard core libraries to be imported automatically") do |b|
53
+ options.use_default_core_libs = !b
54
+ end
55
+ opts.on("-c", "--core-require CORE_LIBRARY", "Require an additional CORE_LIBRARY before executing your script. This is for libraries that allow access to RVM library functions.") do |lib|
56
+ options.core_library << "#{lib}"
57
+ end
58
+
59
+ opts.on("-f", "--function NAMESPACE/FUNCTION", "Require the function before executing your script. This is for rvm internal functions.") do |lib|
60
+ options.rvm_library << "rvm/functions/#{lib}"
61
+ end
62
+
63
+ language_list = (LANGUAGES_ALIASES.keys + LANGUAGES).join(',')
64
+ opts.on("-l", "--language LANGUAGE", LANGUAGES, LANGUAGES_ALIASES, "Select interpreter language", " (#{language_list})") do |language|
65
+ options.language = language
66
+ end
67
+
68
+ # Boolean switch.
69
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
70
+ options.verbose = v
71
+ end
72
+
73
+ opts.on("-d", "--[no-]debug", "Run in debug mode (attention spammy! Implies -v") do |d|
74
+ options.verbose = true if $DEBUG = options.debug = d
75
+ end
76
+
77
+ opts.on("-e", "--execute CODE", "Executes CODE directly.") do |code|
78
+ options.code = code
79
+ end
80
+
81
+ opts.on("-o", "--optimize", "Optimizes the code prior to execution") do
82
+ options.optimize
83
+ end
84
+
85
+ opts.separator ""
86
+ opts.separator "Common options:"
87
+
88
+ # No argument, shows at tail. This will print an options summary.
89
+ # Try it and see!
90
+ opts.on_tail("-h", "--help", "Show this message") do
91
+ puts opts
92
+ exit
93
+ end
94
+
95
+ # Another typical switch to print the version.
96
+ opts.on_tail("--version", "Show version") do
97
+ puts OptionParser::Version.join('.')
98
+ exit
99
+ end
100
+ end
101
+ o.parse!(args)
102
+ options
103
+ end # parse()
104
+
105
+ end # class OptparseExample
106
+
107
+ @options = RVMOptParser.parse(ARGV)
108
+ @compiler = nil
109
+
110
+ def v text
111
+ puts text if @options.verbose
112
+ end
113
+
114
+
115
+ v "Initializing environment."
116
+
117
+ @options.rvm_library.each do |lib|
118
+ v "Loading RVM Library: #{lib}."
119
+ unless require(lib)
120
+ puts "ERROR: could not require internal library: #{lib}"
121
+ exit 1
122
+ end
123
+ end
124
+
125
+ begin
126
+ if require("rvm/languages/#{@options.language}")
127
+ v "Loading Compiler: #{@options.language}"
128
+ @compiler = RVM::Languages[@options.language].new
129
+ else
130
+ puts "ERROR: could not find compiler: #{@options.language}"
131
+ exit 2
132
+ end
133
+ rescue Exception => e
134
+ puts "ERROR: could not load compiler for: #{@options.language} #=> #{e}"
135
+ exit 3
136
+ end
137
+
138
+ if @options.use_default_core_libs
139
+ @env = @compiler.env
140
+ else
141
+ @env = RVM::Initerpreter.env
142
+ end
143
+
144
+ @options.core_library.each do |lib|
145
+ v "Loading core library #{lib}."
146
+ if File.exist?(lib)
147
+ begin
148
+ v "Compiling core library #{lib}."
149
+ code = @compiler.compile(File.read(lib), true)
150
+ v "Optimizing library #{lib}" if @options.optimize
151
+ code = code.optimize if @options.optimize
152
+ begin
153
+ v "Executing library #{lib}."
154
+ code.execute(@env)
155
+ rescue Exception => e
156
+ puts "ERROR: could not execute core library: #{lib} #=> #{e}"
157
+ exit 4
158
+ end
159
+ rescue Exception => e
160
+ puts "ERROR: could not compile core library: #{lib} #=> #{e}"
161
+ exit 5
162
+ end
163
+ else
164
+ puts "ERROR: Could not load core library: #{lib}"
165
+ exit 6
166
+ end
167
+ end
168
+
169
+ @options.library.each do |lib|
170
+ v "Loading library #{lib}."
171
+ if File.exist?(lib)
172
+ begin
173
+ v "Compiling library #{lib}."
174
+ code = @compiler.compile(File.read(lib))
175
+ v "Optimizing library #{lib}" if @options.optimize
176
+ code = code.optimize if @options.optimize
177
+ begin
178
+ v "Executing library #{lib}."
179
+ code.execute(@env)
180
+ rescue Exception => e
181
+ puts "ERROR: could not execute library: #{lib} #=> #{e}"
182
+ exit 4
183
+ end
184
+ rescue Exception => e
185
+ puts "ERROR: could not compile library: #{lib} #=> #{e}"
186
+ exit 5
187
+ end
188
+ else
189
+ puts "ERROR: Could not load library: #{lib}"
190
+ exit 6
191
+ end
192
+ end
193
+
194
+ if @options.code
195
+ v "Executing: #{@options.code}."
196
+ @source = @options.code
197
+ else
198
+ if file = ARGV.first
199
+ if File.exist?(file)
200
+ @source = File.read(file)
201
+ else
202
+ puts "ERROR: Could not load source file: #{file}"
203
+ exit 7
204
+ end
205
+ else
206
+ puts "No files passed."
207
+ puts `#{$0} -h`
208
+ exit 8
209
+ end
210
+ end
211
+
212
+
213
+ begin
214
+ v "Compiling program code."
215
+ code = @compiler.compile(@source)
216
+ # p code
217
+ v "Optimizing library #{lib}" if @options.optimize
218
+ code = code.optimize if @options.optimize
219
+ begin
220
+ v "Executing program code."
221
+ code.execute(@env)
222
+ rescue Exception => e
223
+ puts "ERROR: could not execute program code #=> #{e}"
224
+ raise e
225
+ end
226
+ rescue Exception => e
227
+ puts "ERROR: could not compile program code #=> #{e}"
228
+ raise e
229
+ end
data/lib/rvm.rb CHANGED
@@ -1,7 +1,7 @@
1
- require File.dirname(__FILE__) +'/rvm/interpreter'
2
- require File.dirname(__FILE__) +'/rvm/classes'
3
- require File.dirname(__FILE__) +'/rvm/functions'
4
- require File.dirname(__FILE__) +'/rvm/languages'
1
+ require 'rvm/interpreter'
2
+ require 'rvm/classes'
3
+ require 'rvm/functions'
4
+ require 'rvm/languages'
5
5
  require 'timeout'
6
6
 
7
7
  # This is the rVM library. Including it loads the very basic functionalites rVM offers.
@@ -15,7 +15,7 @@ require 'timeout'
15
15
  #
16
16
  # It also contains some usefull functions that wil allow to make the usuage easyer.
17
17
  module RVM
18
-
18
+ VERSION = "0.0.16" unless defined?(VERSION)
19
19
  # This class is designed to allow execting code more safely
20
20
  #
21
21
  # It allows to limit executin in multiple ways to prevent all sorty of runaway code.
@@ -88,7 +88,7 @@ module RVM
88
88
 
89
89
  # A utility function to give debug output based on weather $DEBUG is set or not
90
90
  def debug text
91
- puts text if $DEBUG
91
+ puts ">>> #{text}" if $DEBUG
92
92
  end
93
93
  end
94
94
  end
@@ -1,3 +1,27 @@
1
+ =begin
2
+ The MIT License
3
+
4
+ Copyright (c) 2007 Heinz N. 'Licenser' Gies
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Ruby Mush"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
23
+ =end
24
+
1
25
 
2
26
  # RVM::ActsAsRVMType is a mixin that allows to quickly publish classes and types
3
27
  # to the rVM interpreter without going through the hassle of defining each
@@ -14,7 +38,6 @@
14
38
  # register_variable :var
15
39
  # register_function :to_s
16
40
  # end
17
-
18
41
  module RVM::ActsAsRVMType
19
42
 
20
43
  # Called when included, loads the class methods and the instance methods needed.
@@ -52,8 +75,8 @@ module RVM::ActsAsRVMType
52
75
  puts self.class
53
76
  @variables = {}
54
77
  #gets the variables hash from the Test class and maps it to a getter/setter Class
55
- self.class.object_variables.each do |name, data|
56
- published_as, writable = data
78
+ self.class.object_variables.each do |published_as, data|
79
+ name, writable = data
57
80
  @variables[published_as.to_s] = RVM::Interpreter::VariableStorageCallback.new(self, name, writable)
58
81
  end
59
82
  #redefinces the variables method to remove overhead from mapping
@@ -5,8 +5,8 @@
5
5
  # This file is published under the MIT Licenser, see LICENSE for details.
6
6
  #
7
7
 
8
- require File.dirname(__FILE__) + '/plugin'
9
- require File.dirname(__FILE__) + '/functions'
8
+ require 'rvm/plugin'
9
+ require 'rvm/functions'
10
10
  module RVM
11
11
  # This module is the basic class container, classes are supposed to be
12
12
  # used by this as in: RVM::Classes[<class id>] this guarnatees that,
@@ -16,11 +16,12 @@ module RVM
16
16
  #
17
17
  # === Creating a string calss
18
18
  #
19
- # require 'lib/base/classes'
19
+ # require 'rvm/classes'
20
20
  # string = RVM::Classes[:string].new
21
21
  module Classes
22
22
  extend RVM::PluginHost
23
23
  default :string
24
+
24
25
  # The Parent for new classes, meant never to be used alone.
25
26
  # It takes care of registering the calss to the PluginHost,
26
27
  # as well of basic functionality.
@@ -30,10 +31,10 @@ module RVM
30
31
  #
31
32
  # == Examples
32
33
  #
33
- # === COMPLES NUMBERS
34
+ # === COMPLEX NUMBERS
34
35
  #
35
- # # file: lib/classes/math/complex.rb
36
- # require 'lib/base/classes'
36
+ # # file: rvm/classes/math/complex.rb
37
+ # require 'rvm/classes'
37
38
  # module RVM
38
39
  # module Classes
39
40
  # class Complex < RVM::Classes::Class
@@ -81,19 +82,12 @@ module RVM
81
82
  :any
82
83
  end
83
84
 
84
- # Returns if the objects is true or not,
85
- # this is interesting for things like errors overwrite it if your
86
- # class is not always true.
87
- def is_true?
88
- true
89
- end
90
-
91
85
  # Redefinding the method to allow using self defined functions
92
86
  # within classes - while this is discuraged it still is possible.
93
87
  def method_missing(m, *args, &block)
94
88
  # Check if the functions PluginHost knwos about the called function
95
89
  if (RVM::Functions::has? m)
96
- # Calls the function with given args and enviroment that is,
90
+ # Calls the function with given args and environment that is,
97
91
  # hopefully defiend in the calling class.
98
92
  RVM::Functions[m].execute args, @env
99
93
  else
@@ -107,5 +101,5 @@ module RVM
107
101
  end
108
102
 
109
103
  Dir[File.dirname(__FILE__) + '/classes/*.rb'].each do |c|
110
- require c
104
+ require 'rvm/classes/' + File.basename(c)
111
105
  end
@@ -16,13 +16,18 @@ module RVM
16
16
  true
17
17
  end
18
18
 
19
+ def optimize
20
+ @code = @code.optimize
21
+ self
22
+ end
23
+
19
24
  def call params, env, pos = nil
20
- RVM::debug "Calling Block at #{pos}...(#{env},#{params})" if $DEBUG
21
- env = RVM::Interpreter::Enviroment.new({:params => params||[]}, env)
25
+ RVM::debug "Calling Block at #{pos}...(evn: #{env}, params: #{params})" if $DEBUG
26
+ env = RVM::Interpreter::Environment .new({:params => params||[]}, env)
22
27
  begin
23
28
  @code.execute(env)
24
29
  rescue RVM::Interpreter::ReturnException => e
25
- RVM::debug "yuck, cought a result!" if $DEBUG
30
+ RVM::debug "yuck, caught a result!" if $DEBUG
26
31
  pp e if $DEBUG
27
32
  return e.val
28
33
  end
@@ -31,14 +31,14 @@ module RVM
31
31
  m = @parent.functions(method) if not m and @parent
32
32
  raise "Unknown method #{method} for object #{self}" if not m
33
33
  params.unshift self
34
- env = RVM::Interpreter::Enviroment.new({:params => params||[], :locals => @variables, :functions => @functions}, env)
34
+ env = RVM::Interpreter::Environment.new({:params => params||[], :locals => @variables, :functions => @functions}, env)
35
35
  m.call(params, env)
36
36
  end
37
37
  end
38
38
 
39
39
  def instance params, env
40
40
  o = RVM::Classes::Object.new self
41
- env = RVM::Interpreter::Enviroment.new({:params => params||[], :locals => @variables, :functions => @functions}, env)
41
+ env = RVM::Interpreter::Environment.new({:params => params||[], :locals => @variables, :functions => @functions}, env)
42
42
  o.obj_send(@initializer, [], env) if @object_functions[@initializer]
43
43
  o
44
44
  end
@@ -1,6 +1,6 @@
1
1
  module RVM
2
2
  module Classes
3
- class List < Array
3
+ class List < ::Array
4
4
  extend Plugin
5
5
  plugin_host Classes
6
6
  register_for :list
@@ -0,0 +1,31 @@
1
+ module RVM
2
+ module Classes
3
+ class Null < RVM::Classes::Class
4
+ register_for :null
5
+
6
+ def data_type
7
+ :null
8
+ end
9
+
10
+ def hash
11
+ nil.hash
12
+ end
13
+
14
+ def eql?(o)
15
+ if o.nil? and o.is_a?(RVM::Classes::Null)
16
+ true
17
+ else
18
+ false
19
+ end
20
+ end
21
+
22
+ def initialize value
23
+ super()
24
+ end
25
+
26
+ def is_true?
27
+ false
28
+ end
29
+ end
30
+ end
31
+ end