Yukihiro "Matz" Matsumoto
b9f771dc50
Handles exceptions from code generation phase; fix #3695
2017-06-07 13:29:08 +09:00
Yukihiro "Matz" Matsumoto
fc7096f18a
Limit recursion level of codegen(); fix #3690
2017-06-05 13:18:31 +09:00
Yukihiro "Matz" Matsumoto
7f417ade42
Revert "Update NODE_BLOCK check logic in void_expr_error."
...
This reverts commit 31e30686b0 .
2017-06-02 13:31:03 +09:00
Yukihiro "Matz" Matsumoto
31e30686b0
Update NODE_BLOCK check logic in void_expr_error.
2017-06-02 13:01:29 +09:00
Yukihiro "Matz" Matsumoto
0f2f021330
Fixed a bug in void_expr_error.
2017-06-02 12:06:40 +09:00
Yukihiro "Matz" Matsumoto
b59d244c0d
Add more precise void expression checks; ref #3686
2017-06-02 11:53:26 +09:00
Yukihiro "Matz" Matsumoto
a893877b0d
Check for super using OP_ARGARY; fix #3678
...
It generates a wasted empty array for each `super` call though.
It should be fixed in the future, if possible.
2017-06-01 09:38:42 +09:00
Yukihiro "Matz" Matsumoto
cbd4aae41c
Mark the proc object representing top-level as an internal object; #3621
2017-05-29 14:13:17 +09:00
Yukihiro "Matz" Matsumoto
5e1a6a2cc2
Make gen_assignment() to support NODE_SCALL; ref #3658
2017-05-25 12:40:49 +09:00
Clayton Smith
bf30b8e8bf
Change return back to break in the default case.
2017-05-12 14:43:12 -04:00
Yukihiro "Matz" Matsumoto
88cd807379
Avoid use of snprintf() when DISABLE_STDIO is set; fix #3632
...
ref #3492 #3515 #3517
2017-04-25 10:41:50 +09:00
Nobuyoshi Nakada
d54f9f8f78
Fix embedded document with unterminated terminator
...
`skips()` is `mrb_bool` function, should return `FALSE` at EOF, not
`EOF`.
2017-04-23 11:41:00 +09:00
Yukihiro "Matz" Matsumoto
3b0a36d399
Alias should push() extra stack space for blocks.
2017-04-22 12:03:56 +09:00
Yukihiro "Matz" Matsumoto
f4119f518f
Changed evaluation order of yield; ref #3613
...
So that `yield expr_with_error` will cause the error from the
argument rather than `LocalJumpError` when no block is given.
2017-04-18 12:00:52 +09:00
Yukihiro "Matz" Matsumoto
3123549bcb
Fixed a bug in NODE_XSTR code generation; fix #3605
2017-04-13 00:38:47 +09:00
Yukihiro "Matz" Matsumoto
326e043a64
Exceptions may be raised in yyparse(); fix #3600
2017-04-12 10:23:34 +09:00
Yukihiro "Matz" Matsumoto
fff4a4ed34
OP_LAMBDA generation should honor VAL/NOVAL; fix #3580
2017-04-11 02:30:24 +09:00
Yukihiro "Matz" Matsumoto
77331d127b
Unify else clause style
2017-04-03 16:56:27 +09:00
Yukihiro "Matz" Matsumoto
666787beb2
Adjust exit point in loop_pop(); fix #3541
2017-04-03 12:41:27 +09:00
Yukihiro "Matz" Matsumoto
d35fcf1ea2
NODE_SPLAT to pass VAL/NOVAL; fix #3532
2017-04-03 12:02:39 +09:00
Yukihiro "Matz" Matsumoto
a14a930c80
Remove unnecessary indirection; ref #3557
2017-04-03 10:03:58 +09:00
Yukihiro "Matz" Matsumoto
8193c0b566
Check before generating special operators (e.g. OP_ADD); fix #3557
2017-04-03 10:01:44 +09:00
Yukihiro "Matz" Matsumoto
dcbfe71625
NODE_ASGN arguments may be 127 (CALL_MAXARGS) accidentally; fix #3559
2017-04-01 14:11:15 +09:00
Yukihiro "Matz" Matsumoto
e22f37a166
Argument order of __case_eqq was wrong; fix #3567
2017-04-01 13:42:44 +09:00
Yukihiro "Matz" Matsumoto
051e40c049
Use MRB_PRId for NODE_NTH_REF; ref #3530
2017-03-23 01:52:52 +09:00
Yukihiro "Matz" Matsumoto
9eb0c11afd
Cast to mrb_int to silence a warning; fix #3530
2017-03-23 01:20:45 +09:00
Yukihiro "Matz" Matsumoto
3703aed7ab
Use snprintf() to stringify fixnum numbers; ref #3492
2017-03-20 11:47:15 +09:00
Yukihiro "Matz" Matsumoto
4cf38eb903
Fixed OP_RESCUE code generation bug; fix #3519
...
916b8e let code executed with mrb->exc set, and may cause a crash
like #3519 . Instead modified OP_RESCUE again. To retrieve the exception
object, we use `OP_RESCUE R(A), 0, 0` (old behavior). To compare the
exception object and the class, we use `OP_RESCUE R(A), R(B), 1`.
The reason we use OP_RESCUE for two instruction switched by operand
C is to save the instruction space.
As a result, the following code:
```ruby
begin
raise "a"
rescue TypeError
p 1
rescue RuntimeError
p 2
end
```
will be compiled as:
```
irep 0x55cd1f565cb0 nregs=4 nlocals=1 pools=1 syms=4 reps=0
file: -
2 000 OP_ONERR 005
2 001 OP_LOADSELF R1
2 002 OP_STRING R2 L(0) ; "a"
2 003 OP_SEND R1 :raise 1
2 004 OP_JMP 023
2 005 OP_RESCUE R1
3 006 OP_GETCONST R2 :TypeError
3 007 OP_RESCUE R1 R2 cont
3 008 OP_JMPIF R2 010
3 009 OP_JMP 014
4 010 OP_LOADSELF R1
4 011 OP_LOADI R2 1
4 012 OP_SEND R1 :p 1
4 013 OP_JMP 024
5 014 OP_GETCONST R2 :RuntimeError
5 015 OP_RESCUE R1 R2 cont
5 016 OP_JMPIF R2 018
5 017 OP_JMP 022
6 018 OP_LOADSELF R1
6 019 OP_LOADI R2 2
6 020 OP_SEND R1 :p 1
6 021 OP_JMP 024
6 022 OP_RAISE R1
6 023 OP_POPERR 1
6 024 OP_STOP
```
2017-03-19 18:42:53 +09:00
Yukihiro "Matz" Matsumoto
916b8ed5c8
Generate new OP_RESCUE; fix #3487
...
The old OP_RESCUE took one operand A, which specifies a class
to match with the exception. The new OP_RESCUE takes tree operands:
A: the register to hold exception
B: the matching exception; the match result will be stored here.
C: the continuation; if C is zero, the exception will be stored to R(A)
otherwise, the value from R(A) is used as a exception.
Thus,
```ruby
begin
raise "a"
rescue TypeError
p 1
rescue RuntimeError
p 2
end
```
will be compiled as
```
irep 0x557a06667aa0 nregs=4 nlocals=1 pools=1 syms=4 reps=0
file: /tmp/e.rb
2 000 OP_ONERR 005
2 001 OP_LOADSELF R1
2 002 OP_STRING R2 L(0) ; "a"
2 003 OP_SEND R1 :raise 1
2 004 OP_JMP 022
3 005 OP_GETCONST R2 :TypeError
3 006 OP_RESCUE R1 R2
3 007 OP_JMPIF R2 009
3 008 OP_JMP 013
4 009 OP_LOADSELF R1
4 010 OP_LOADI R2 1
4 011 OP_SEND R1 :p 1
4 012 OP_JMP 023
5 013 OP_GETCONST R2 :RuntimeError
5 014 OP_RESCUE R1 R2 cont
5 015 OP_JMPIF R2 017
5 016 OP_JMP 021
6 017 OP_LOADSELF R1
6 018 OP_LOADI R2 2
6 019 OP_SEND R1 :p 1
6 020 OP_JMP 023
6 021 OP_RAISE R1
6 022 OP_POPERR 1
6 023 OP_STOP
```
The new VM can accept old OP_RESCUE. The mruby compatible VM (namely
mruby/c) should be updated to support the new OP_RESCUE behavior.
2017-03-12 01:10:20 +09:00
Yukihiro "Matz" Matsumoto
26169f9e25
Enhance OP_RESCUE to take B operand fas matching exception; ref #3487
2017-03-12 00:50:38 +09:00
Yukihiro "Matz" Matsumoto
000c68da97
OP_RETRUN to take B as matching exception; ref #3487
2017-03-11 16:32:29 +09:00
Yukihiro "Matz" Matsumoto
63dbed0094
__FILE__ should not update p->filename; fix #3485
2017-03-07 15:01:09 +09:00
Yukihiro "Matz" Matsumoto
1ab7e7e4dc
Fixed a bug in register size calculation; fix #3479
2017-03-02 18:14:36 +09:00
Yukihiro "Matz" Matsumoto
0bcf9e28fc
Reorganize C++ exceptions; ref #3470
...
There are 3 levels of C++ exception handling:
* default - no C++ exception (use setjmp/longjmp)
* enable_cxx_exception (use C++ exceptions with C ABI)
* enable_cxx_abi (use C++ ABI including exceptions)
2017-03-02 10:58:26 +09:00
Yukihiro "Matz" Matsumoto
8b089c09f7
Keep space for safe navigation operator; fix #3475
2017-03-01 10:37:43 +09:00
Yukihiro "Matz" Matsumoto
cd0ac59dd3
Newlines in strings should be counted; fix #3477
2017-03-01 00:05:54 +09:00
Yukihiro "Matz" Matsumoto
dc56bbecc8
Ignore empty ensure clause.
2017-02-28 11:51:17 +09:00
Yukihiro "Matz" Matsumoto
fb3243e096
return (and break) should handle splat correctly; fix #3472
2017-02-28 11:34:54 +09:00
Yukihiro "Matz" Matsumoto
22eb41ab20
Fix NODE_DREGX dump; ref #3471
2017-02-28 10:56:34 +09:00
Yukihiro "Matz" Matsumoto
c52bbe1b4e
Fixed a bug in dregex option generation; fix #3471
2017-02-28 10:43:22 +09:00
Yukihiro "Matz" Matsumoto
89eac4f59d
Update codegen.c comments
2017-02-28 10:32:40 +09:00
Tomoyuki Sahara
da4f8e19fa
replace "yylval" with "pylval" to make it compile with byacc.
2017-02-24 11:47:48 +09:00
Yukihiro "Matz" Matsumoto
ecb6ac8b4a
Fixed codegen error of redo in rescue; fix #3422
...
The issue (and the fix) was reported by https://hackerone.com/dgaletic
2017-02-13 19:31:06 +09:00
Yukihiro "Matz" Matsumoto
f2b18a604c
Check maximum number of formal arguments.
...
http://hkdnet.hatenablog.com/entry/2017/02/06/080000 (Japanese)
2017-02-06 09:14:49 +09:00
Yukihiro "Matz" Matsumoto
6e0ba0085d
Jump address should fit in 16 bits range; fix #3426
2017-02-04 12:37:08 +09:00
Yukihiro "Matz" Matsumoto
f0f095bc13
Fix a double free problem in codegen.c; fix #3378
...
This issue was first reported by https://hackerone.com/geeknik
The fix was proposed by @titanous
2017-01-23 16:53:31 +09:00
Yukihiro "Matz" Matsumoto
3ce82603a5
Fix memory leak; ref #3378
...
The fix was proposed by @titanous
2017-01-23 16:48:18 +09:00
Clayton Smith
797ff625f3
Fix incorrect parsing of block parameters.
2017-01-21 09:08:37 -05:00
Clayton Smith
2c0f8f1a23
Remove problematic optimization.
2017-01-20 18:40:18 -05:00
Yukihiro "Matz" Matsumoto
c2bbfa5b61
NODE_NEGATE cdr may not be code-node; fix #3348 ref #3324
...
Reported by Denis Kasak https://hackerone.com/dkasak
2016-12-18 02:02:30 +09:00