module Myco
Constants
- BasicDecorators
- BasicObject
- Category
- Decorator
- EmptyObject
- FileToplevel
This empty, barebones component will be replaced after bootstrapping.
- Instance
- Loop
- MYCO_REQUIRED_GEMS
- MYCO_VERSION
- Object
- Pegleromyces
- Ruby
- RubyEval
- SingletonClass
- Switch
- ToolSet
- Void
Public Class Methods
activate_required_gems()
click to toggle source
TODO: move elsewhere?
# File lib/myco/version.rb, line 11 def self.activate_required_gems MYCO_REQUIRED_GEMS.each do |name, version| gem name, version end end
add_dynamic_method(mod, name, file="(dynamic)", line=1) { |g| ... }
click to toggle source
Use instead of Module#dynamic_method
# File lib/myco/bootstrap/add_method.rb, line 21 def self.add_dynamic_method mod, name, file="(dynamic)", line=1 g = Rubinius::ToolSets::Runtime::Generator.new g.name = name.to_sym g.file = file.to_sym g.set_line Integer(line) yield g g.close g.use_detected g.encode code = g.package Rubinius::CompiledCode cscope = Rubinius::ConstantScope.new(mod, Rubinius::ConstantScope.new(Myco)) add_method(mod, name, code, cscope) end
add_method(mod, name, executable, cscope)
click to toggle source
In Myco
, try to always use Myco.add_method
instead of Rubinius.add_method to bypass all of the Ruby-specific logic therein.
# File lib/myco/bootstrap/add_method.rb, line 6 def self.add_method mod, name, executable, cscope mod.method_table.store(name, nil, executable, cscope, 0, :public) Rubinius::VM.reset_method_cache(mod, name) end
add_thunk_method(mod, name, value)
click to toggle source
Use instead of Module#thunk_method
# File lib/myco/bootstrap/add_method.rb, line 16 def self.add_thunk_method mod, name, value add_method(mod, name, Rubinius::Thunk.new(value), nil) end
branch_op(type, left) { || ... }
click to toggle source
Logical branching operator with lazy evaluation of right hand
# File lib/myco/misc.rb, line 5 def self.branch_op type, left case type when :"&&"; return left if left.false? when :"||"; return left unless left.false? when :"??"; return left unless left.void? when :"&?"; return ::Myco::Void if left.false? when :"|?"; return ::Myco::Void unless left.false? end return yield # evaluate and return right hand end
cscope()
click to toggle source
Get the “current” ConstantScope (from the caller’s perspective)
# File lib/myco/bootstrap/find_constant.rb, line 131 def self.cscope Rubinius::ConstantScope.of_sender end
eval(string, call_depth:1)
click to toggle source
TODO: deprecate with proper import set of functions
# File lib/myco/eval.rb, line 5 def self.eval string, call_depth:1 loader = Myco::CodeLoader::MycoLoader.new("(eval)") loader.bind_to(call_depth: call_depth + 1) loader.string = string loader.load end
eval_file(path, load_paths=nil, get_last=true, scope=Rubinius::ConstantScope.new(::Myco, nil))
click to toggle source
TODO: deprecate with proper import set of functions
# File lib/myco/eval.rb, line 13 def self.eval_file path, load_paths=nil, get_last=true, scope=Rubinius::ConstantScope.new(::Myco, nil) load_paths ||= [File.dirname(Rubinius::VM.backtrace(1).first.file)] file_toplevel = CodeLoader.load(path, load_paths, cscope:scope, call_depth:1) get_last ? file_toplevel.component.__last__ : file_toplevel.component end
find_constant(name, scope=Rubinius::ConstantScope.of_sender)
click to toggle source
# File lib/myco/bootstrap/find_constant.rb, line 135 def self.find_constant(name, scope=Rubinius::ConstantScope.of_sender) scope.get_myco_constant_ref(name).value end
rescue() { || ... }
click to toggle source
TODO: replace backtrace in a different way, without this hack
# File lib/myco/eval.rb, line 20 def self.rescue begin yield rescue Exception=>e unless e.is_a? SystemExit puts e.awesome_backtrace.show puts e.awesome_backtrace.first_color + e.message + "\033[0m" puts exit(1) end end end
tuple(*ary)
click to toggle source
# File lib/myco/bootstrap/tuple.rb, line 9 def tuple(*ary) ary.__tuple__ end