Module: AmberVM

Defined in:
lib/amber.rb,
lib/amber/plugin.rb,
lib/amber/classes.rb,
lib/amber/library.rb,
lib/amber/functions.rb,
lib/amber/languages.rb,
lib/amber/environment.rb,
lib/amber/interpreter.rb,
lib/amber/classes/list.rb,
lib/amber/classes/null.rb,
lib/amber/optimisation.rb,
lib/amber/classes/block.rb,
lib/amber/classes/class.rb,
lib/amber/classes/error.rb,
lib/amber/classes/number.rb,
lib/amber/classes/object.rb,
lib/amber/classes/string.rb,
lib/amber/languages/ecma.rb,
lib/amber/languages/math.rb,
lib/amber/classes/boolean.rb,
lib/amber/functions/array/at.rb,
lib/amber/functions/io/print.rb,
lib/amber/functions/list/map.rb,
lib/amber/functions/logic/or.rb,
lib/amber/functions/math/abs.rb,
lib/amber/functions/math/add.rb,
lib/amber/functions/math/cos.rb,
lib/amber/functions/math/dec.rb,
lib/amber/functions/math/div.rb,
lib/amber/functions/math/exp.rb,
lib/amber/functions/math/inc.rb,
lib/amber/functions/math/log.rb,
lib/amber/functions/math/mod.rb,
lib/amber/functions/math/mul.rb,
lib/amber/functions/math/neg.rb,
lib/amber/functions/math/shl.rb,
lib/amber/functions/math/shr.rb,
lib/amber/functions/math/sin.rb,
lib/amber/functions/math/sub.rb,
lib/amber/functions/math/tan.rb,
lib/amber/classes/association.rb,
lib/amber/functions/list/join.rb,
lib/amber/functions/logic/and.rb,
lib/amber/functions/logic/not.rb,
lib/amber/functions/math/acos.rb,
lib/amber/functions/math/asin.rb,
lib/amber/functions/math/atan.rb,
lib/amber/functions/math/ceil.rb,
lib/amber/functions/math/rand.rb,
lib/amber/languages/brainfuck.rb,
lib/amber/languages/ecma_fuku.rb,
lib/amber/languages/math/tree.rb,
lib/amber/functions/general/eq.rb,
lib/amber/functions/general/gt.rb,
lib/amber/functions/general/lt.rb,
lib/amber/functions/list/align.rb,
lib/amber/functions/list/split.rb,
lib/amber/functions/math/floor.rb,
lib/amber/functions/math/power.rb,
lib/amber/functions/math/round.rb,
lib/amber/functions/string/chr.rb,
lib/amber/functions/general/cmp.rb,
lib/amber/functions/general/gte.rb,
lib/amber/functions/general/lte.rb,
lib/amber/functions/general/neq.rb,
lib/amber/functions/rails/print.rb,
lib/amber/functions/string/ansi.rb,
lib/amber/functions/array/append.rb,
lib/amber/functions/array/set_at.rb,
lib/amber/functions/general/type.rb,
lib/amber/functions/objects/send.rb,
lib/amber/functions/string/ljust.rb,
lib/amber/functions/string/rjust.rb,
lib/amber/functions/string/capstr.rb,
lib/amber/functions/string/center.rb,
lib/amber/languages/ecma/compiler.rb,
lib/amber/languages/math/compiler.rb,
lib/amber/functions/collection/get.rb,
lib/amber/functions/collection/set.rb,
lib/amber/languages/math/tokenizer.rb,
lib/amber/functions/collection/size.rb,
lib/amber/functions/string/regmatch.rb,
lib/amber/functions/bitwise/bitwise_or.rb,
lib/amber/languages/ecma_fuku/compiler.rb,
lib/amber/functions/bitwise/bitwise_and.rb,
lib/amber/functions/bitwise/bitwise_not.rb,
lib/amber/functions/bitwise/bitwise_xor.rb,
lib/amber/functions/association/assoc_get.rb,
lib/amber/functions/association/assoc_set.rb

Overview

The MIT License

Copyright © 2008 Heinz N. ‘Licenser’ Gies

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Ruby Mush”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Defined Under Namespace

Modules: ActsAsAmberVMType, Classes, Functions, Interpreter, Languages, Plugin, PluginHost Classes: Library, Safety

Constant Summary collapse

VERSION =
"0.0.19"
@@strict =
false

Class Method Summary collapse

Class Method Details

.compile(language, code) ⇒ Object

Compils a code the given language. A new compiler is created for that and discarded afterwards.

Using compiler_for and calling compile for it yourself is more performant if you plan on doing thise more then once.



76
77
78
# File 'lib/amber.rb', line 76

def compile language, code
  compiler_for(language).compile(code)
end

.compiler_for(language) ⇒ Object

Creates you a compiler object for the given language. If no language is given a error is raised.



82
83
84
85
86
87
88
# File 'lib/amber.rb', line 82

def compiler_for language
  if (l = AmberVM::Languages[language])
    l.new
  else
    raise "AmberVM Error: Unknown Language #{language}"
  end
end

.debug(text) ⇒ Object

A utility function to give debug output based on weather $DEBUG is set or not



91
92
93
94
95
96
97
# File 'lib/amber.rb', line 91

def debug text
  if $HTML_DEBUG
    puts "<p><pre>" + (">>> #{text}".gsub("<","&lt;").gsub('>','&gt;').gsub("\n","<br/>\n"))+ "</pre></p>"
  else
    puts ">>> #{text}"
  end
end

.require_plugin(path) ⇒ Object

Convenience method for plugin loading. The syntax used is:

AmberVM.require_plugin '<Host ID>/<Plugin ID>'

Returns the loaded plugin.



329
330
331
332
333
334
335
# File 'lib/amber/plugin.rb', line 329

def self.require_plugin path
  host_id, plugin_id = path.split '/', 2
  host = PluginHost.host_by_id(host_id)
  raise PluginHost::HostNotFound,
    "No host for #{host_id.inspect} found." unless host
  host.load plugin_id
end

.strictObject

This getter returns if rVM handles types strict.

Calling a method with wrong types will raise a error if this is true. If false rVM will try to typecast accordingly.



61
62
63
# File 'lib/amber.rb', line 61

def strict
  @@strict
end

.strict=(v) ⇒ Object

Sets if variables are strictly typed or casted for function calls. This allows to make a language either more secure or more flexible.



67
68
69
# File 'lib/amber.rb', line 67

def strict= v
  @@strict = v
end