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
@@ -62,6 +62,10 @@ module RVM
62
62
  @value
63
63
  end
64
64
 
65
+ def pretty_print(q)
66
+ q.text @value.to_s
67
+ end
68
+
65
69
  #alias :respond_to_number :respond_to?
66
70
  #def respond_to?(symbol,include_private = false)
67
71
  # respond_to_number(symbol,include_private)
@@ -18,7 +18,7 @@ module RVM
18
18
  m = @functions[method] || @object_class.object_functions(method)
19
19
  raise "Unknown method #{method} for object #{self}" if not m
20
20
  params.unshift self
21
- env = RVM::Interpreter::Enviroment.new({:params => params||[], :locals => @variables}, env)
21
+ env = RVM::Interpreter::Environment.new({:params => params||[], :locals => @variables}, env)
22
22
  m.call(params, env)
23
23
  end
24
24
 
@@ -19,7 +19,8 @@ module RVM
19
19
  'm' => 35, 'M' => 45,
20
20
  'c' => 36, 'C' => 45,
21
21
  'w' => 37, 'W' => 47,
22
- }
22
+ } unless defined?(ANSI_MAP)
23
+
23
24
  def initialize val = ""
24
25
  super val.to_s
25
26
  end
@@ -69,6 +70,10 @@ module RVM
69
70
  c = "\e[#{colorcode}m"
70
71
  self.class.new("#{c}#{self.gsub("\e[0m",c)}\e[0m")
71
72
  end
73
+
74
+ def value
75
+ to_s
76
+ end
72
77
  end
73
78
  end
74
79
  end
@@ -0,0 +1,256 @@
1
+ module RVM
2
+ module Interpreter
3
+ # This class represents the environment, the memory so to say for the VM.
4
+ # The environment holds environmental variables like who executes the
5
+ # code, on what object it runs, what parameters where passed to the call
6
+ # and as well, and perhaps most importantly the local variables.
7
+ #
8
+ # Some of the functions called will initialize new environments, as
9
+ # for example function calls.
10
+ class Environment
11
+ # This creates a new environment environment, it generates a new env
12
+ # default variables are set if not defined in +data+.
13
+ #
14
+ # If +oldenv+ is provided it will also fall back to see if not
15
+ # existing variables
16
+ #
17
+ # +init_data+ is a hash that can be passed the following values:
18
+ # :locals:: A hash with local variables mapped name => value
19
+ # :functions:: A hash with functions for the scope.
20
+ # :evaldeepth:: A fixnum that indicates how deep the evaluation is.
21
+ # :params:: A array that holds local parameters for example for functions
22
+ # or blocks.
23
+ def initialize init_data = {}, oldenv=nil
24
+
25
+ @data = {
26
+ :locals => {}, #oldenv ? oldenv.data[:locals] : {},
27
+ :locals_swapped => true, # init_data.keys.include?(:locals),
28
+ :functions => oldenv ? oldenv.data[:functions] : {},
29
+ :functions_swapped => init_data.keys.include?(:functions),
30
+ :evaldeepth => 0,
31
+ :params => oldenv ? oldenv.data[:params] : [],
32
+ :params_swapped => init_data.keys.include?(:params)
33
+ }.merge(init_data)
34
+ @path = [] if oldenv.nil?
35
+
36
+ # Make sure that all locals that are passed, are actually in a variable
37
+ # storage.
38
+ if init_data[:locals]
39
+ # For easy access we get us a link to the locals
40
+ locals = @data[:locals]
41
+ # Now we itterate through them
42
+ init_data[:locals].each do |k,v|
43
+ #For every variable that isn't already in a storage
44
+ if not v.is_a?(VariableStorage)
45
+ # We put it in a storage to assure the environment is propper.
46
+ locals[k] = VariableStorage.new(v)
47
+ end
48
+ end
49
+ end
50
+
51
+ # We store the priviouse environment to look upwards through the scopes
52
+ # for priviouse defined variables, if no old environment was given we
53
+ # set the priviose scope to an empty hash.
54
+ @prev = oldenv || {}
55
+ RVM::debug "data: #{data}\noldenv:#{oldenv}" if $DEBUG
56
+ RVM::debug "Creating new environment with: #{@data.inspect} as child" +
57
+ " of #{@prev}" if $DEBUG
58
+ end
59
+
60
+
61
+ # Allows raw access to the data, it should not be used unless
62
+ # somoene knows pretty exactly what they are doing.
63
+ def data
64
+ @data
65
+ end
66
+
67
+ def path
68
+ @path || @pre.path
69
+ end
70
+
71
+ # returns a parameter that was passed to the call. For function calls
72
+ # this is especially important, it beginns with 0.
73
+ #
74
+ # If the current environment does not have the given paramenter it tries
75
+ # it's 'oldenv' attrib to see if that had a object.
76
+ def param i
77
+ RVM::debug "Getting param #{i} (#{@data[:params][i]})" if $DEBUG
78
+ if @data[:params_swapped]
79
+ @data[:params][i] || @prev.param(i)
80
+ else
81
+ @data[:params][i]
82
+ end
83
+ end
84
+
85
+ # Returns a local variable with the given name.
86
+ #
87
+ # If the current environment does not have any local variables with
88
+ # the given name it tries the privious environments.
89
+ #
90
+ # This returns the +VariableData+ object NOT the value of the variable.
91
+ # Use +read_var_val+ if you want to read the value of a variable.
92
+ def [] k
93
+
94
+ r = @data[:locals][k]
95
+ r = @prev[k] if not r and @data[:locals_swapped]
96
+ RVM::debug "Getting variable #{k} (#{r})" if $DEBUG
97
+ r
98
+ end
99
+
100
+ # Sets a local variable witin the environment.
101
+ #
102
+ # If the variable exists in a 'higher' environment the value is changed.
103
+ #
104
+ # If not it is newly created in the current environment and thus not
105
+ # visible in upper environments.
106
+ def []= name, value
107
+ RVM::debug "Setting variable #{name} to #{value}" if $DEBUG
108
+
109
+ # First we try to get the variable storage of the variable requested.
110
+ # This will work if it was defined in this or a priviouse scope.
111
+ if storage = self[name]
112
+ # If we found the storage we'll change it's value and not define it
113
+ # again.
114
+ storage.val = value
115
+ else
116
+ # If we didn't found a Variable storage, the variable wasn't defined
117
+ # before so we make a new VariableStorage and save the variable in
118
+ # it.
119
+ declare name, value
120
+ end
121
+ value
122
+ end
123
+
124
+ # Defines a varialbe in the current scope, priviose variables are not
125
+ # changed.
126
+ # This is needed for local varialbe declarations that overwrite priviouse
127
+ # globals.
128
+ def declare name, value
129
+ #Now we need to make our own set of storage!
130
+ if not @data[:locals_swapped]
131
+ @data[:locals_swapped] = true
132
+ @data[:locals] = {}
133
+ end
134
+ @data[:locals][name] = VariableStorage.new(value)
135
+ end
136
+
137
+ # Returns a function for the environment. If the current environment does
138
+ # not hold a function with the requested name it checks through the
139
+ # entire tree if a function can be found in the outer scopes.
140
+ #
141
+ # The result is to be execpted to be of the +RVM::Classes::Block+ class.
142
+ def function name
143
+ # Try to get the function in the local defintions.
144
+ fun = @data[:functions][name]
145
+ # if that fails and we have a previous environment check that
146
+ fun = @prev.function(name) if fun.nil? and @data[:functions_swapped] and @prev.is_a? Environment
147
+ RVM::debug "Getting functon #{name} (#{fun})" if $DEBUG
148
+ # return what was found
149
+ fun
150
+ end
151
+
152
+ # This defines a function within the environment and lets you call it later
153
+ # on.
154
+ #
155
+ # It expects the body to be a RVM::Classes::Block so it can be executed.
156
+ # The return value is the given block
157
+ def def_function name, body
158
+ if not body.is_a?(RVM::Classes::Block)
159
+ raise(ArgumentError, "Function definitions must be of block class.")
160
+ end
161
+
162
+ #Now we need to make our own set of storage!
163
+ if not @data[:functions_swapped]
164
+ @data[:functions_swapped] = true
165
+ @data[:functions] = {}
166
+ end
167
+
168
+ @data[:functions][name] = body
169
+ RVM::debug "Setting functon #{name} (#{body})" if $DEBUG
170
+ body
171
+ end
172
+
173
+ # This functin is closely related to +[]+ with the difference that it
174
+ # returns the value and not the VariableStorage object.
175
+ # It is equivalent to [].val just that it also deals with nil ojects and
176
+ # and returns a RVM::Classes::Error if the requested variable wasn't
177
+ # found.
178
+ def read_var_val name
179
+
180
+ r = nil
181
+ if (v = self[name])
182
+ r = v.val
183
+ else
184
+ raise "Variable #{name} is not defined."
185
+ end
186
+ RVM::debug "Getting variable value #{name} (#{r})" if $DEBUG
187
+ r
188
+ end
189
+ end
190
+ # This class is used to store the variable content to allow chross
191
+ # refferencing and passing variables upwards through different scopes.
192
+ class VariableStorage
193
+
194
+ # Lets the script read the value of the variable.
195
+ attr_reader :val
196
+
197
+ # The storage is initialized with two optional parameters:
198
+ #
199
+ # +val+:: which is the value to be stores.
200
+ # +writable+:: which when set to false prevents the variable to be
201
+ # written, which might be helpfull when trying to publish
202
+ # some data to a script that is not supposed to be changed.
203
+ def initialize val = nil, writable = true
204
+ @writable = writable
205
+ @val = val
206
+ end
207
+
208
+ # Used to write to the variable, if +writable+ was set to false this
209
+ # will have no effect.
210
+ #
211
+ # It returns the new value set or, if +writable+ was false the old value.
212
+ def val=v
213
+ @val = v if @writable
214
+ @val
215
+ end
216
+ end
217
+
218
+ # The callback storang is used to help publishing variables from a ruby
219
+ # class to the rVM, it will get and set the variables during runtime.
220
+ #
221
+ # It will link getter and setter methods and not the instance variable
222
+ # itself, which means also computed attributes can be handled by this.
223
+ #
224
+ # This class is made if it is nessessary that a script always has access
225
+ # to constantly chaning data within a object and not only deal with static
226
+ # values set once.
227
+ class VariableStorageCallback < VariableStorage
228
+ # The construtor takes 3 parameters to specifie the object it shold
229
+ # be linked with, the attribute to handle and +writable+ that will define
230
+ # if the VariableStorage can be written too by the script.
231
+ #
232
+ # var is expected to by a Symbol equal the the function, the getter will
233
+ # call obj.var and the setter will call obj.var=.
234
+ #
235
+ def initialize obj, var, writable = true
236
+ super(nil, writable)
237
+ @obj = obj
238
+ @get = var.to_sym
239
+ @set = "#{var}=".to_sym
240
+ end
241
+
242
+ # This methods sets the variable passed to the object by sending it to
243
+ # the setter method.
244
+ def val= v
245
+ @obj.send(@set,v) if @writable
246
+ @obj.send(@get)
247
+ end
248
+
249
+ # The getter will call the getter of the object to handle to get the
250
+ # current value.
251
+ def val
252
+ @obj.send(@get)
253
+ end
254
+ end
255
+ end
256
+ end
@@ -1,5 +1,5 @@
1
- require File.dirname(__FILE__) + '/plugin'
2
- require File.dirname(__FILE__) + '/interpreter'
1
+ require 'rvm/plugin'
2
+ require 'rvm/interpreter'
3
3
  module RVM
4
4
  # This module holds all the functions laded for the rVM to to keep them
5
5
  # organized and handle which are accassabel and which not.
@@ -49,8 +49,9 @@ module RVM
49
49
  # is set.
50
50
  # This is what you want if you call a function to ensure all parameters
51
51
  # are passed correctly.
52
- def call params, env, pos = nil
52
+ def call params, env, pos = []
53
53
  i = 0
54
+ pos ||= []
54
55
  # We want to make sure that if we don't have signatures from the
55
56
  # function we have a default signature of any to prevent automatic
56
57
  # type castng in that case
@@ -75,7 +76,11 @@ module RVM
75
76
  p
76
77
  end if not signature.empty?
77
78
  # Now we execute the function code and cache the esult
78
- r = execute(params, env)
79
+ begin
80
+ r = execute(params, env)
81
+ rescue Exception => e
82
+ raise "#{e} at #{pos.join(':')}"
83
+ end
79
84
  # print a debug message if needed
80
85
  RVM::debug "#{self.inspect}: #{signature.inspect} = '#{r}'" if $DEBUG
81
86
  r
@@ -1,6 +1,30 @@
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
  Dir[File.dirname(__FILE__) + '/array/*.rb'].each do |c|
2
- require c
26
+ require 'rvm/functions/array/' + File.basename(c)
3
27
  end
4
28
  Dir[File.dirname(__FILE__) + '/collection/*.rb'].each do |c|
5
- require c
29
+ require 'rvm/functions/collection/' + File.basename(c)
6
30
  end
@@ -1,5 +1,35 @@
1
- module RVM
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
+
25
+ module RVM
2
26
  module Functions
27
+
28
+ # The Append function takes two arguments. The first an List or and anything
29
+ # else as a second parameter.
30
+ #
31
+ # It will take the List and append the second parameter passed to it to this
32
+ # list in the very end.
3
33
  class Append < Function
4
34
  def Append.execute params, env
5
35
  if params.length == 2
@@ -1,5 +1,33 @@
1
- module RVM
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
+
25
+ module RVM
2
26
  module Functions
27
+
28
+ # The At function is used to access elements for a List, it takes the List
29
+ # the get the element from as a first argument and the position to get it
30
+ # from, a Number, as the second.
3
31
  class At < Function
4
32
  class << self
5
33
  def execute params, env
@@ -1,5 +1,34 @@
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
+
25
+
1
26
  module RVM
2
27
  module Functions
28
+
29
+ # This Function is used to set a element of a List on a specific position.
30
+ # The List is passed as first and the position, a Number, passed as second
31
+ # parameter.
3
32
  class SetAt < Function
4
33
  def SetAt.execute params, env
5
34
  if params.length == 3