2000-05-01 09:42:38 +00:00
|
|
|
/**********************************************************************
|
1998-01-16 12:13:05 +00:00
|
|
|
|
|
|
|
inits.c -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Tue Dec 28 16:01:58 JST 1993
|
|
|
|
|
* encoding.c: provide basic features for M17N.
* parse.y: encoding aware parsing.
* parse.y (pragma_encoding): encoding specification pragma.
* parse.y (rb_intern3): encoding specified symbols.
* string.c (rb_str_length): length based on characters.
for older behavior, bytesize method added.
* string.c (rb_str_index_m): index based on characters. rindex as
well.
* string.c (succ_char): encoding aware succeeding string.
* string.c (rb_str_reverse): reverse based on characters.
* string.c (rb_str_inspect): encoding aware string description.
* string.c (rb_str_upcase_bang): encoding aware case conversion.
downcase, capitalize, swapcase as well.
* string.c (rb_str_tr_bang): tr based on characters. delete,
squeeze, tr_s, count as well.
* string.c (rb_str_split_m): split based on characters.
* string.c (rb_str_each_line): encoding aware each_line.
* string.c (rb_str_each_char): added. iteration based on
characters.
* string.c (rb_str_strip_bang): encoding aware whitespace
stripping. lstrip, rstrip as well.
* string.c (rb_str_justify): encoding aware justifying (ljust,
rjust, center).
* string.c (str_encoding): get encoding attribute from a string.
* re.c (rb_reg_initialize): encoding aware regular expression
* sprintf.c (rb_str_format): formatting (i.e. length count) based
on characters.
* io.c (rb_io_getc): getc to return one-character string.
for older behavior, getbyte method added.
* ext/stringio/stringio.c (strio_getc): ditto.
* io.c (rb_io_ungetc): allow pushing arbitrary string at the
current reading point.
* ext/stringio/stringio.c (strio_ungetc): ditto.
* ext/strscan/strscan.c: encoding support.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 03:29:39 +00:00
|
|
|
Copyright (C) 1993-2007 Yukihiro Matsumoto
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2000-05-01 09:42:38 +00:00
|
|
|
**********************************************************************/
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2019-12-04 17:16:30 +09:00
|
|
|
#include "internal/inits.h"
|
|
|
|
#include "ruby.h"
|
2019-11-15 03:51:06 +09:00
|
|
|
#include "builtin.h"
|
2019-12-29 10:07:17 +09:00
|
|
|
static void Init_builtin_prelude(void);
|
2019-11-15 03:51:06 +09:00
|
|
|
#include "prelude.rbinc"
|
1998-01-16 12:13:05 +00:00
|
|
|
|
2008-11-07 13:52:07 +00:00
|
|
|
#define CALL(n) {void Init_##n(void); Init_##n();}
|
1998-01-16 12:19:22 +00:00
|
|
|
|
1998-01-16 12:13:05 +00:00
|
|
|
void
|
2008-11-07 13:52:07 +00:00
|
|
|
rb_call_inits(void)
|
1998-01-16 12:13:05 +00:00
|
|
|
{
|
2020-06-30 22:19:18 +01:00
|
|
|
CALL(Thread_Mutex);
|
2018-11-01 08:53:44 +00:00
|
|
|
#if USE_TRANSIENT_HEAP
|
2018-10-30 21:53:56 +00:00
|
|
|
CALL(TransientHeap);
|
2018-11-01 08:53:44 +00:00
|
|
|
#endif
|
2018-11-08 05:35:46 +00:00
|
|
|
CALL(vm_postponed_job);
|
2014-09-18 00:36:37 +00:00
|
|
|
CALL(Method);
|
2015-11-30 20:32:42 +00:00
|
|
|
CALL(RandomSeedCore);
|
2019-04-13 17:05:58 +01:00
|
|
|
CALL(encodings);
|
2008-11-07 13:52:07 +00:00
|
|
|
CALL(sym);
|
|
|
|
CALL(var_tables);
|
|
|
|
CALL(Object);
|
|
|
|
CALL(top_self);
|
|
|
|
CALL(Encoding);
|
|
|
|
CALL(Comparable);
|
|
|
|
CALL(Enumerable);
|
|
|
|
CALL(String);
|
|
|
|
CALL(Exception);
|
|
|
|
CALL(eval);
|
|
|
|
CALL(jump);
|
|
|
|
CALL(Numeric);
|
|
|
|
CALL(Bignum);
|
|
|
|
CALL(syserr);
|
|
|
|
CALL(Array);
|
|
|
|
CALL(Hash);
|
|
|
|
CALL(Struct);
|
|
|
|
CALL(Regexp);
|
2019-12-29 10:07:17 +09:00
|
|
|
CALL(pack);
|
2008-11-07 13:52:07 +00:00
|
|
|
CALL(transcode);
|
|
|
|
CALL(marshal);
|
|
|
|
CALL(Range);
|
|
|
|
CALL(IO);
|
|
|
|
CALL(Dir);
|
|
|
|
CALL(Time);
|
|
|
|
CALL(Random);
|
|
|
|
CALL(signal);
|
|
|
|
CALL(load);
|
|
|
|
CALL(Proc);
|
|
|
|
CALL(Binding);
|
|
|
|
CALL(Math);
|
2019-12-29 10:07:17 +09:00
|
|
|
CALL(GC);
|
2008-11-07 13:52:07 +00:00
|
|
|
CALL(Enumerator);
|
2020-03-10 02:22:11 +09:00
|
|
|
CALL(Ractor);
|
2008-11-07 13:52:07 +00:00
|
|
|
CALL(VM);
|
|
|
|
CALL(ISeq);
|
|
|
|
CALL(Thread);
|
2021-02-09 19:39:56 +13:00
|
|
|
CALL(Fiber_Scheduler);
|
2014-09-12 19:42:01 +00:00
|
|
|
CALL(process);
|
2008-11-07 13:52:07 +00:00
|
|
|
CALL(Cont);
|
|
|
|
CALL(Rational);
|
|
|
|
CALL(Complex);
|
2020-09-25 20:32:02 +09:00
|
|
|
CALL(MemoryView);
|
2008-11-07 13:52:07 +00:00
|
|
|
CALL(version);
|
2019-12-29 10:07:17 +09:00
|
|
|
CALL(vm_trace);
|
2018-09-11 09:48:58 +00:00
|
|
|
CALL(vm_stack_canary);
|
2019-12-29 10:07:17 +09:00
|
|
|
CALL(ast);
|
2019-04-24 12:52:57 +09:00
|
|
|
CALL(gc_stress);
|
2019-11-07 16:58:00 +09:00
|
|
|
|
2019-11-15 03:51:06 +09:00
|
|
|
// enable builtin loading
|
2019-11-07 16:58:00 +09:00
|
|
|
CALL(builtin);
|
2020-05-16 17:37:28 +09:00
|
|
|
}
|
2019-11-07 18:22:08 +09:00
|
|
|
|
2020-05-16 17:37:28 +09:00
|
|
|
void
|
|
|
|
rb_call_builtin_inits(void)
|
|
|
|
{
|
2019-12-29 10:07:17 +09:00
|
|
|
#define BUILTIN(n) CALL(builtin_##n)
|
|
|
|
BUILTIN(gc);
|
2020-03-10 02:22:11 +09:00
|
|
|
BUILTIN(ractor);
|
2021-01-02 11:39:07 +09:00
|
|
|
BUILTIN(numeric);
|
2019-12-29 10:07:17 +09:00
|
|
|
BUILTIN(io);
|
2020-01-18 13:59:21 +09:00
|
|
|
BUILTIN(dir);
|
2019-12-29 10:07:17 +09:00
|
|
|
BUILTIN(ast);
|
|
|
|
BUILTIN(trace_point);
|
|
|
|
BUILTIN(pack);
|
|
|
|
BUILTIN(warning);
|
2020-01-26 18:27:40 +09:00
|
|
|
BUILTIN(array);
|
2020-03-17 19:37:07 +09:00
|
|
|
BUILTIN(kernel);
|
2020-12-31 17:23:37 +09:00
|
|
|
BUILTIN(timev);
|
2021-06-03 12:04:56 +09:00
|
|
|
BUILTIN(nilclass);
|
2021-09-18 15:34:15 +02:00
|
|
|
BUILTIN(marshal);
|
Directly link libcapstone for easier development
This lets us use libcapstone directly from miniruby so we don't need a
Ruby Gem to to dev work.
Example usage:
```ruby
def foo(x)
if x < 1
"wow"
else
"neat"
end
end
iseq = RubyVM::InstructionSequence.of(method(:foo))
puts UJIT.disasm(iseq)
100.times { foo 1 }
puts UJIT.disasm(iseq)
```
Then in the terminal
```
$ ./miniruby test.rb
== disasm: #<ISeq:foo@test.rb:1 (1,0)-(7,3)> (catch: FALSE)
local table (size: 1, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] x@0<Arg>
0000 getlocal_WC_0 x@0 ( 2)[LiCa]
0002 putobject_INT2FIX_1_
0003 opt_lt <calldata!mid:<, argc:1, ARGS_SIMPLE>
0005 branchunless 10
0007 putstring "wow" ( 3)[Li]
0009 leave ( 7)[Re]
0010 putstring "neat" ( 5)[Li]
0012 leave ( 7)[Re]
== ISEQ RANGE: 10 -> 10 ========================================================
0x0: movabs rax, 0x7fe816e2d1a0
0xa: mov qword ptr [rdi], rax
0xd: mov r8, rax
0x10: mov r9, rax
0x13: mov r11, r12
0x16: jmp qword ptr [rax]
== ISEQ RANGE: 0 -> 7 ==========================================================
0x0: mov rax, qword ptr [rdi + 0x20]
0x4: mov rax, qword ptr [rax - 0x18]
0x8: mov qword ptr [rdx], rax
0xb: mov qword ptr [rdx + 8], 3
0x13: movabs rax, 0x7fe817808200
0x1d: test byte ptr [rax + 0x3e6], 1
0x24: jne 0x3ffff7b
0x2a: test byte ptr [rdx], 1
0x2d: je 0x3ffff7b
0x33: test byte ptr [rdx + 8], 1
0x37: je 0x3ffff7b
0x3d: mov rax, qword ptr [rdx]
0x40: cmp rax, qword ptr [rdx + 8]
0x44: movabs rax, 0
0x4e: movabs rcx, 0x14
0x58: cmovl rax, rcx
0x5c: mov qword ptr [rdx], rax
0x5f: test qword ptr [rdx], -9
0x66: jne 0x3ffffd5
```
Make sure to `brew install pkg-config capstone`
2021-01-22 10:43:26 -08:00
|
|
|
BUILTIN(ujit);
|
2019-12-29 10:07:17 +09:00
|
|
|
Init_builtin_prelude();
|
1998-01-16 12:13:05 +00:00
|
|
|
}
|
2008-11-07 13:52:07 +00:00
|
|
|
#undef CALL
|