aboutsummaryrefslogtreecommitdiffstats
path: root/tool/mk_builtin_loader.rb
Commit message (Collapse)AuthorAgeFilesLines
* Calculate header line count instead of hardcodingNobuyoshi Nakada2020-06-281-1/+2
|
* Replace separators in input file name in header tooNobuyoshi Nakada2020-06-281-4/+4
|
* Replace ALT_SEPARATOR with SEPARATOR also in output file nameNobuyoshi Nakada2020-06-281-1/+5
| | | | | | | | To suppress warnings by Visual C. ``` ./integer.rb(5) : warning C4129: 'i' : unrecognized character escape sequence ./kernel.rb(21) : warning C4129: 'k' : unrecognized character escape sequence ```
* Introduce Primitive.attr! to annotate 'inline' (#3242)Takashi Kokubun2020-06-201-0/+6
| | | [Feature #15589]
* [Feature #16254] Allow `Primitive.func` styleNobuyoshi Nakada2020-06-191-0/+5
|
* [Feature #16254] Allow `__builtin.func` styleNobuyoshi Nakada2020-06-191-3/+20
|
* Support arguments of singleton methodNobuyoshi Nakada2020-06-141-0/+1
|
* Fixed up rest, keywords, keyword rest and block argumentsNobuyoshi Nakada2020-06-141-2/+9
|
* Make __builtin_cexpr! and __builtin_cstmt! work againTakashi Kokubun2020-06-131-2/+17
| | | | | | | | | | | with Ripper. a3e6f52c17061f012c4e638b3343b57752ed7603 introduced __builtin_cexpr! and __builtin_cstmt!, but nobody has used them and then they broke on 79292b30884ebcd8be028a7f3c9ccafd7759f2ae by undefined `params`. This patch fixes the undefined `params`, but still we're not using them yet.
* Make builtin loader sources by RipperNobuyoshi Nakada2020-05-191-44/+70
|
* Also scan `rescue` clausesNobuyoshi Nakada2020-04-041-1/+1
|
* Separate builtin initialization callsNobuyoshi Nakada2019-12-291-1/+1
|
* decouple internal.h headers卜部昌平2019-12-261-2/+7
| | | | | | | | | | | | | | | | | | Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies).
* Fixed a typo in an exception class nameNobuyoshi Nakada2019-12-231-1/+1
|
* readable function names for inline functions.Koichi Sasada2019-12-131-20/+52
| | | | | | | Now, C functions written by __builtin_cexpr!(code) and others are named as "__builtin_inline#{n}". However, it is difficult to know what the function is. This patch rename them into "__builtin_foo_#{lineno}" when cexpr! is in 'foo' method.
* rename __builtin_inline!(code) and introduce others.Koichi Sasada2019-11-271-22/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rename __builtin_inline!(code) to __builtin_cstmt(code). Also this commit introduce the following inlining C code features. * __builtin_cstmt!(STMT) (renamed from __builtin_inline!) Define a function which run STMT implicitly and call this function at evatuation time. Note that you need to return some value in STMT. If there is a local variables (includes method parameters), you can read these values. static VALUE func(ec, self) { VALUE x = ...; STMT } Usage: def double a # a is readable from C code. __builtin_cstmt! 'return INT2FIX(FIX2INT(a) * 2);' end * __builtin_cexpr!(EXPR) Define a function which invoke EXPR implicitly like `__builtin_cstmt!`. Different from cstmt!, which compiled with `return EXPR;`. (`return` and `;` are added implicitly) static VALUE func(ec, self) { VALUE x = ...; return EXPPR; } Usage: def double a __builtin_cexpr! 'INT2FIX(FIX2INT(a) * 2)' end * __builtin_cconst!(EXPR) Define a function which invoke EXPR implicitly like cexpr!. However, the function is called once at compile time, not evaluated time. Any local variables are not accessible (because there is no local variable at compile time). Usage: GCC = __builtin_cconst! '__GNUC__' * __builtin_cinit!(STMT) STMT are writtein in auto-generated code. This code does not return any value. Usage: __builtin_cinit! '#include <zlib.h>' def no_compression? __builtin_cconst! 'Z_NO_COMPRESSION ? Qtrue : Qfalse' end
* Write rbinc files to the source directoryNobuyoshi Nakada2019-11-261-3/+11
| | | | | Update the target file itself of the dependency on this script. Fall back to the current working directory if unwritable.
* Strip the last line which become trailing spacesNobuyoshi Nakada2019-11-121-1/+1
|
* Get rid of `__` prefix which is presereved by C standardNobuyoshi Nakada2019-11-121-1/+1
|
* __builtin_inline!Koichi Sasada2019-11-111-5/+53
| | | | | | | | | | | | | | | | | Add an experimental `__builtin_inline!(c_expression)` special intrinsic which run a C code snippet. In `c_expression`, you can access the following variables: * ec (rb_execution_context_t *) * self (const VALUE) * local variables (const VALUE) Not that you can read these variables, but you can not write them. You need to return from this expression and return value will be a result of __builtin_inline!(). Examples: `def foo(x) __builtin_inline!('return rb_p(x);'); end` calls `p(x)`. `def double(x) __builtin_inline!('return INT2NUM(NUM2INT(x) * 2);')` returns x*2.
* Full-path of builtin scripts no longer neededNobuyoshi Nakada2019-11-091-4/+2
|
* Revert "don't embed full-path."Koichi Sasada2019-11-091-1/+2
| | | | | | This reverts commit dfac2e9eb3d697e56d91151584f1d3cf9d2c79c9. It does not work if cwd is different from builddir...
* don't embed full-path.Koichi Sasada2019-11-091-2/+1
| | | | | | | miniruby load *.rb from srcdir. To specify file path, tool/mk_builtin_loader.rb embed full path of each *.rb file. However it prevent to pre-generation of required files for tarball. This patch generate srcdir/*.rb from __FILE__ information.
* tool/mk_builtin_loader.rb: check if op is an array or notYusuke Endoh2019-11-081-1/+1
| | | | The insn array includes not only an array but also some literal objects.
* Add file mode to generated files [ci skip]Nobuyoshi Nakada2019-11-081-0/+1
|
* Renamed `load_*.inc` as `*.rbinc` to utilize a suffix ruleNobuyoshi Nakada2019-11-081-2/+2
|
* Stop compiling if type mismatch was found.Koichi Sasada2019-11-081-0/+6
| | | | | | | | | | | If there is a type mismatch between expected builtin function type and actual function type, C compiler shows warning. For example, `__builtin_func(1, 2)` expects `func(rb_ec_t*, VALUE self, VALUE p1, VALUE p2)` function definition. However, it is easy to overlook "warning" messages. So this patch changes to stop compiling as an error if there is a mismatch.
* support builtin features with Ruby and C.Koichi Sasada2019-11-081-0/+76
Support loading builtin features written in Ruby, which implement with C builtin functions. [Feature #16254] Several features: (1) Load .rb file at boottime with native binary. Now, prelude.rb is loaded at boottime. However, this file is contained into the interpreter as a text format and we need to compile it. This patch contains a feature to load from binary format. (2) __builtin_func() in Ruby call func() written in C. In Ruby file, we can write `__builtin_func()` like method call. However this is not a method call, but special syntax to call a function `func()` written in C. C functions should be defined in a file (same compile unit) which load this .rb file. Functions (`func` in above example) should be defined with (a) 1st parameter: rb_execution_context_t *ec (b) rest parameters (0 to 15). (c) VALUE return type. This is very similar requirements for functions used by rb_define_method(), however `rb_execution_context_t *ec` is new requirement. (3) automatic C code generation from .rb files. tool/mk_builtin_loader.rb creates a C code to load .rb files needed by miniruby and ruby command. This script is run by BASERUBY, so *.rb should be written in BASERUBY compatbile syntax. This script load a .rb file and find all of __builtin_ prefix method calls, and generate a part of C code to export functions. tool/mk_builtin_binary.rb creates a C code which contains binary compiled Ruby files needed by ruby command.