Yukihiro "Matz" Matsumoto
3141b9424c
mruby-compiler/y.tab.c: it will be generated by Lrama from parse.y
...
No longer need to bundle in the repository.
2024-06-10 15:34:16 +09:00
Yukihiro "Matz" Matsumoto
fbe21a0321
tools/lrama: bundle Lrama 0.6.9 (copied from CRuby source)
2024-06-10 14:26:26 +09:00
Yukihiro "Matz" Matsumoto
d6da2d4760
mruby-compiler: use @1 in parse.y to enable YYLTYPE
...
This change itself does nothing good, but it is a preparation for the
future Bison to Lrama migration. As of 0.6.9, Lrama has a compatibility
issue for grammar files without `@n`.
2024-06-10 08:23:36 +09:00
Yukihiro "Matz" Matsumoto
889af10090
mruby-compiler: prohibit dynamic assignment to constants; #3521
...
Along with some declaration adjustments to minimize `y.tab.c` diff.
2024-06-05 18:56:11 +09:00
Yukihiro "Matz" Matsumoto
87b358a342
Including header files in include/* by <>
2024-03-26 13:59:59 +09:00
Yukihiro "Matz" Matsumoto
a810b9bca8
mruby-compiler/codegen.c: stop too aggressive optimization; fix #6210
...
The old code assumes unary minus (`-@`) does not cause any side effect
(including errors). Considering the code like `-nil; nil`, the
assumption was too aggressive.
2024-03-19 13:38:05 +09:00
Yukihiro "Matz" Matsumoto
6de4df3b31
parse.y: replace mrbc_ prefix by mrb_ccontext
2023-12-06 15:32:13 +09:00
Yukihiro "Matz" Matsumoto
d7b2e3ab14
mruby-compiler/parse.y: add print name for identifier tokens
2023-09-05 23:29:24 +09:00
Yukihiro "Matz" Matsumoto
2f7f797473
remove extra spaces before ;
2023-05-22 12:05:35 +09:00
Yukihiro "Matz" Matsumoto
c32f7915fb
reformat else clause indentation style
2023-05-20 00:21:01 +09:00
dearblue
c981e151ae
Sign extension with OP_LOADI32 in get_int_operand()
...
Previously, the following code did not give the expected result.
```
% bin/mruby -e 'p "%08X" % ~(-1 << 16)'
"..F0000FFFF"
% ruby32 -e 'p "%08X" % ~(-1 << 24)'
"00FFFFFF"
```
For information: this problem arises in the process of folding numbers through optimisation.
2023-04-15 20:52:43 +09:00
Yukihiro "Matz" Matsumoto
bdbc613ccb
parse.y (mrbc_filename): should not raise exceptions
2023-03-22 17:33:49 +09:00
Yukihiro "Matz" Matsumoto
7f79ca2cf6
mruby-compiler: need to adjust the line number for do_block; fix #5949
2023-03-11 15:49:35 +09:00
Yukihiro "Matz" Matsumoto
e6cf932d38
fixup! mruby/internal.h: add codedump functions to the internal function header
2023-01-18 10:37:48 +09:00
Yukihiro "Matz" Matsumoto
55eea005c8
mruby/internal.h: add codedump functions to the internal function header
...
ref #5906
2023-01-18 10:37:48 +09:00
dearblue
c101261f45
Call mrb_env_unshare() in mrb_top_run() if necessary
...
This is to keep the local variables of the previously created blocks consistent in case the `mrbc_context` passed to `mrb_load_exec()` is `NULL` or different.
Switching between `mrbc_context` pointers that are non `NULL` can be done safely by calling `mrbc_cleanup_local_variables()`.
Before this patch, the result of the following code is not as expected.
```console
% cat loadstr.c
#include <mruby.h>
#include <mruby/compile.h>
int
main(int argc, char *argv[])
{
mrb_state *mrb = mrb_open();
mrb_load_string(
mrb,
"(a, b, c, d, e, f, g) = [1, 2, 3, 4, 5, 6, 7] \n"
"$lambda = -> { p [a, b, c, d, e, f, g] }");
mrb_load_string(mrb, "$lambda.call");
mrb_close(mrb);
return 0;
}
% $(bin/mruby-config --cc --cflags --ldflags) loadstr.c $(bin/mruby-config --libs) && ./a.out
[main, nil, nil, main, nil, nil, main]
```
Also, since `mrb_env_unshare()` was not used before, the internal stack of simply detached `env` objects could show invalid addresses by `stack_extend()`.
ref. https://github.com/kou/mruby-pp/commit/ef5951aca870183d8767cb61f6414240988ca35e
2023-01-09 22:47:37 +09:00
Yukihiro "Matz" Matsumoto
f7a8a42521
mruby-compiler/parse.y: allow multiple anonymous splat in args rule
...
For example, this should be allowed:
```ruby
def f(*)
p(*,*)
end
```
2022-12-17 09:37:44 +09:00
Yukihiro "Matz" Matsumoto
855e63e17c
parse.y: avoid using mrb_bug(); ref #5852
2022-11-25 16:17:29 +09:00
Yukihiro "Matz" Matsumoto
9c5dc42e59
small cosmetic changes.
...
I prefer `i++` style unless absolutely necessary.
This commit is an addition to 41e4148.
2022-11-19 17:11:56 +09:00
Yukihiro "Matz" Matsumoto
4a888a34bb
readfloat.c (mrb_read_float): a new function.
...
We no longer use `mrb_float_read()` that depends on `errno`.
2022-11-07 16:09:31 +09:00
Yukihiro "Matz" Matsumoto
4e9773ae3d
readint.c (mrb_int_read): new function.
...
We no longer use `mrb_read_int` which is kinda compatible with `strtol`.
2022-11-07 16:09:31 +09:00
Yukihiro "Matz" Matsumoto
4f385f119c
parse.y (call_with_block): a->cdr may be NULL.
2022-11-04 14:05:52 +09:00
fn ⌃ ⌥
273fcbc347
ops.h: update OP_ARYDUP instruction and rename to OP_ARYSPLAT.
...
Transforms the value of a splat inside a return statement (similar
to an array). For example, `return *nil` should return `nil.to_a`,
while `return *1` should return `[1]`
2022-10-29 19:54:34 -07:00
Yukihiro "Matz" Matsumoto
ce86585281
Merge pull request #5812 from FnControlRuby/block
...
parse.y: fix return/break/next with method call with args and block
2022-10-29 16:29:41 +09:00
Yukihiro "Matz" Matsumoto
02f44d76fc
codegen.c: stop peephole optimization for headless case statement.
...
This fixes #5815
2022-10-28 15:57:35 +09:00
Yukihiro "Matz" Matsumoto
9ff247c5c2
Revert "codegen.c: exit headless case early if a condition is always true"
...
This reverts commit e5b32e559860073632fc7b69cb98b90f2c069e81; ref #5815
2022-10-28 15:54:40 +09:00
fn ⌃ ⌥
fee8f540c6
parse.y: fix return/break/next with method call with args and block
2022-10-21 20:01:08 -07:00
fn ⌃ ⌥
e5b32e5598
codegen.c: exit headless case early if a condition is always true
2022-10-21 20:00:44 -07:00
fn ⌃ ⌥
6ba44f64d5
parse.y: fix NODE_REGX dump
2022-10-18 20:56:00 -07:00
Yukihiro "Matz" Matsumoto
751ac378bd
codegen.c: should not skip rhs array; fix #5797
...
When the value of multiple assignment taken, the rhs array needs to be
generated anyway.
2022-10-01 15:18:45 +09:00
Yukihiro "Matz" Matsumoto
7c0f7e2665
parse.y: allow NUMPARAMs (e.g. _1) as hash keys; fix #5785
2022-08-23 18:36:26 +09:00
Yukihiro "Matz" Matsumoto
a641f146fc
codegen.c (gen_assignment): use nsym() instead of simple type cast.
2022-08-23 11:30:54 +09:00
Yukihiro "Matz" Matsumoto
108875c972
codegen.c (gen_assignment): support NODE_COLON3 as lhs; fix #5752
...
We should allow `::C = 1` for example.
2022-08-23 07:53:23 +09:00
dearblue
5bc15dd69b
Fixed assertion in ARGUMENT_NORMALIZE() for bidx.
...
It should be compared to the `irep->nregs` value as is.
At the same time, discovered problems have been fixed.
2022-08-04 22:43:06 +09:00
dearblue
43fdce5019
Protected proc objects given by OP_DEF on registers
...
If a GC occurs in `mrb_calloc()` called by `mt_rehash()` inside `mrb_define_method_raw(), the `proc` may be destroyed.
2022-07-30 22:34:50 +09:00
Yukihiro "Matz" Matsumoto
c2e4b82d84
codegen.c (new_litbint): remove surrounding braces.
...
It was to allow local variable declarations, but now we allow
declarations in the middle.
2022-07-26 13:55:54 +09:00
Yukihiro "Matz" Matsumoto
e8ce82bf31
codegen.c (new_litbint): forgot else in a107b85.
2022-07-26 00:11:53 +09:00
Yukihiro "Matz" Matsumoto
c6bf4eaac0
codegen.c (new_litbint): renamed from new_litbn.
2022-07-25 15:33:43 +09:00
Yukihiro "Matz" Matsumoto
a107b850eb
codegen.c (new_bitbn): fixed wrong packing of integer radix.
2022-07-25 15:31:43 +09:00
Yukihiro "Matz" Matsumoto
2b07489372
codegen.c: keep stack space for block argument.
2022-07-20 14:27:02 +09:00
Yukihiro "Matz" Matsumoto
e1980d7596
numeric.c (mrb_div_int): separate the function in two.
...
- mrb_div_int() does integer division in Ruby way (mdiv)
returns mrb_int
- mrb_div_int_value() division with zero div and overflow checks.
returns mrb_value
2022-07-09 14:38:18 +09:00
Yukihiro "Matz" Matsumoto
ce89ab8660
parse.y: class cannot be followed by modifier if. [ruby-bugs:18884]
2022-07-02 10:31:33 +09:00
Yukihiro "Matz" Matsumoto
7005f8661b
parse.y (paser_pfree): recycle memory if possible.
2022-06-15 07:28:05 +09:00
Yukihiro "Matz" Matsumoto
561dffcccc
parse.y: fix nested here-document bug; fix #5607
...
- remove `lex_strterm_before_heredoc` that does not nest
- remove `all_heredocs` that cannot distinguish nested and followed
here-doc
- replace `lex_strterm` represented by cons list by C struct
- push/pop `lex_strterm` before/after interpolation
2022-06-13 22:25:37 +09:00
Yukihiro "Matz" Matsumoto
3cab2e7b78
mruby-compiler: remove spaces before * in type casting.
2022-06-13 17:00:30 +09:00
Yukihiro "Matz" Matsumoto
b1f6c856e3
parse.y (nextc0): small refactoring.
2022-06-08 21:59:51 +09:00
Yukihiro "Matz" Matsumoto
0d2c550f0f
parse.y: use info as abbreviation for information.
...
Replace `inf` that looks like abbreviation for `infinity`.
2022-06-07 18:42:53 +09:00
Yukihiro "Matz" Matsumoto
9cc9c9fe63
parse.y (heredoc_treat_nextline): simplify the logic using append().
2022-06-06 08:00:04 +09:00
Yukihiro "Matz" Matsumoto
81fb3c5a4b
parse.y: need to update p->lex_strterm in heredoc_treat_nextline().
2022-06-06 08:00:03 +09:00
Yukihiro "Matz" Matsumoto
5233865c47
codegen.c (search_upvar): update messages for anonymous parameters.
2022-06-03 13:00:13 +09:00