Skip to content

Instantly share code, notes, and snippets.

@benolee
Last active December 16, 2015 16:40
Show Gist options
  • Save benolee/5465200 to your computer and use it in GitHub Desktop.
Save benolee/5465200 to your computer and use it in GitHub Desktop.

r5 Notes

here's most of the core classes, modules, traits, and methods. i probably missed some, but it's a start.

the number after method names is the arity.

# Classes:

Object
  #==, 1
  #initialize, -1
  #kind_of?, 1
  #methods, 0
  #print, 0
  #to_s, 0

Class
  #new_subclass, 1
  #run_body, 1
  #add_method, 2
  #uses, 1
  #allocate, 0
  #new, -1
  #<, 1
  #===, 1
  #name, 0

Trait
  .new, 2
  #run_body, 1
  #add_method, 2

Importer
  .current, 0
  #import, 1
  #load, 1

ImportError

os.buffer.Buffer
  #allocate, 0
  #initialize, 1
  #clear, 0
  #flip, 0
  #rewind, 0
  #string, 1

Integer
  .cast, 1
  #+, 1
  #to_s, 0
  #==, 1
  #<, 1

Method
  #eval, -1
  #call, -1
  #|, -1

Code

NilClass

TrueClass
  #to_s, 0
FalseClass
  #to_s, 0

Dictionary
  #::, 1
  #[], 1
  #keys, 0
  .literal, -1

List

String
  #==, 1

Tuple
  #find_all, 1
  #each, 1
  #==, 1

Exception
  #message, 0
  #show, 0
  RuntimeError
    ArgumentError
    ImportError
    NoMethodError

# Modules:

sys::modules
sys::args
io
  .puts, 1
  .print, 1
os
  .dir
  .file
  .buffer

# Traits:

Enumerable
  #any?
  #detect
  #grep
  #map
vm/ast.cpp:447: S.push(S.string(String::internalize(S.MS, "add_method")));
vm/builtin/os.buffer.cpp:56: S.add_method(cls, "allocate", Buffer_allocate, 0);
vm/builtin/os.buffer.cpp:57: S.add_method(cls, "initialize", Buffer_initialize, 1);
vm/builtin/os.buffer.cpp:58: S.add_method(cls, "clear", Buffer_clear, 0);
vm/builtin/os.buffer.cpp:59: S.add_method(cls, "flip", Buffer_flip, 0);
vm/builtin/os.buffer.cpp:60: S.add_method(cls, "rewind", Buffer_rewind, 0);
vm/builtin/os.buffer.cpp:61: S.add_method(cls, "string", Buffer_string, 1);
vm/builtin/os.dir.cpp:37: S.add_method(cls, "allocate", Dir_allocate, 0);
vm/builtin/os.dir.cpp:38: S.add_method(cls, "initialize", Dir_initialize, 1);
vm/builtin/os.dir.cpp:39: S.add_method(cls, "read", Dir_read, 0);
vm/builtin/os.dir.cpp:40: S.add_method(cls, "close", Dir_close, 0);
vm/builtin/os.file.cpp:54: S.add_method(cls, "allocate", File_allocate, 0);
vm/builtin/os.file.cpp:55: S.add_method(cls, "initialize", File_initialize, 1);
vm/builtin/os.file.cpp:56: S.add_method(cls, "read", File_read, 0);
vm/builtin/os.file.cpp:57: S.add_method(cls, "fill", File_fill, 1);
vm/builtin/os.file.cpp:58: S.add_method(cls, "close", File_close, 0);
vm/cimple.cpp:69: void CimpleState::add_method(String* n, int a) {
vm/cimple.cpp:443: S.add_method(name_, arity);
vm/cimple.cpp:462: S.puts(" S.add_method(cls, \"allocate\", %s_allocate, 0);",
vm/cimple.cpp:470: S.puts(" S.add_method(cls, \"%s\", %s_%s, %d);",
vm/cimple.hpp:189: void add_method(String* n, int a);
vm/class.cpp:50: void Class::add_method(State& S, const char* name,
vm/class.cpp:69: klass()->add_method(S, name, func, arity);
vm/class.hpp:46: void add_method(State& S, const char* name, SimpleFunc func, int arity);
vm/dictionary.cpp:45: dict->add_method(S, "::", get_m, 1);
vm/dictionary.cpp:46: dict->add_method(S, "[]", get_m, 1);
vm/dictionary.cpp:47: dict->add_method(S, "keys", keys_m, 0);
vm/environment.cpp:100: static Handle add_method(State& S, Handle recv, Arguments& args) {
vm/environment.cpp:118: static Handle trait_add_method(State& S, Handle recv, Arguments& args) {
vm/environment.cpp:402: o->add_method(S, "print", object_print, 0);
vm/environment.cpp:403: o->add_method(S, "kind_of?", object_kind_of, 1);
vm/environment.cpp:404: o->add_method(S, "==", object_equal, 1);
vm/environment.cpp:405: o->add_method(S, "to_s", object_to_s, 0);
vm/environment.cpp:407: c->add_method(S, "new_subclass", class_new_subclass, 1);
vm/environment.cpp:408: c->add_method(S, "run_body", run_class_body, 1);
vm/environment.cpp:410: c->add_method(S, "add_method", add_method, 2);
vm/environment.cpp:411: c->add_method(S, "uses", uses_trait, 1);
vm/environment.cpp:412: c->add_method(S, "allocate", alloc_instance, 0);
vm/environment.cpp:413: c->add_method(S, "new", new_instance, -1);
vm/environment.cpp:415: c->add_method(S, "<", class_subclass, 1);
vm/environment.cpp:416: c->add_method(S, "===", class_tequal, 1);
vm/environment.cpp:417: c->add_method(S, "name", class_name, 0);
vm/environment.cpp:419: trait->add_method(S, "run_body", run_trait_body, 1);
vm/environment.cpp:420: trait->add_method(S, "add_method", trait_add_method, 2);
vm/environment.cpp:423: o->add_method(S, "initialize", init_instance, -1);
vm/environment.cpp:424: o->add_method(S, "methods", object_methods, 0);
vm/environment.cpp:428: i->add_method(S, "+", int_plus, 1);
vm/environment.cpp:429: i->add_method(S, "to_s", int_to_s, 0);
vm/environment.cpp:430: i->add_method(S, "==", int_equal, 1);
vm/environment.cpp:431: i->add_method(S, "<", int_lt, 1);
vm/environment.cpp:439: mc->add_method(S, "eval", run_code, -1);
vm/environment.cpp:440: mc->add_method(S, "call", method_call, -1);
vm/environment.cpp:441: mc->add_method(S, "|", method_call, -1);
vm/environment.cpp:444: t->add_method(S, "to_s", true_to_s, 0);
vm/environment.cpp:447: f->add_method(S, "to_s", false_to_s, 0);
vm/environment.cpp:450: tuple->add_method(S, "find_all", tuple_find_all, 1);
vm/environment.cpp:451: tuple->add_method(S, "each", tuple_each, 1);
vm/environment.cpp:452: tuple->add_method(S, "==", tuple_equal, 1);
vm/environment.cpp:472: exc->add_method(S, "message", exc_message, 0);
vm/environment.cpp:473: exc->add_method(S, "show", exc_show, 0);
vm/environment.cpp:499: io->add_method(S, "puts", io_puts, 1);
vm/environment.cpp:500: io->add_method(S, "print", io_print, 1);
vm/import.cpp:123: x->add_method(S, "import", import, 1);
vm/list.cpp:71: list->add_method(S, "[]", aref, 1);
vm/list.cpp:72: list->add_method(S, "each", each, 1);
vm/list.cpp:73: list->add_method(S, "size", size_m, 0);
vm/list.cpp:74: list->add_method(S, "<<", append, 1);
vm/list.cpp:75: list->add_method(S, "==", equal, 1);
vm/module.cpp:35: mod->add_method(S, "add_method", module_add, 2);
vm/module.cpp:36: mod->add_method(S, "::", module_access, 1);
vm/module.cpp:37: mod->add_method(S, "values", values_m, 0);
vm/module.cpp:50: void Module::add_method(State& S, const char* name,
vm/module.cpp:53: klass()->add_method(S, name, func, arity);
vm/module.hpp:19: void add_method(State& S, const char* name, SimpleFunc func, int arity);
vm/state.cpp:53: void State::add_method(Handle cls, const char* name, SimpleFunc ptr, int arity){
vm/state.cpp:54: cls->as_class()->add_method(*this, name, ptr, arity);
vm/state.hpp:78: void add_method(Handle mod, const char* name, SimpleFunc ptr, int arity);
vm/string.cpp:124: str->add_method(S, "bytesize", byte_size, 0);
vm/string.cpp:125: str->add_method(S, "size", char_size, 0);
vm/string.cpp:126: str->add_method(S, "prefix?", prefix_p, 1);
vm/string.cpp:127: str->add_method(S, "==", equal_m, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment