Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
a1795525
Unverified
Commit
a1795525
authored
Dec 19, 2021
by
Yukihiro "Matz" Matsumoto
Committed by
GitHub
Dec 19, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5602 from dearblue/no-ext-ops
Add `bin/mrbc --no-ext-ops` switch
parents
d7812bd3
6b8582c9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
0 deletions
+22
-0
include/mruby/compile.h
include/mruby/compile.h
+2
-0
mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c
mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c
+7
-0
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
+11
-0
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
+1
-0
mrbgems/mruby-compiler/core/y.tab.c
mrbgems/mruby-compiler/core/y.tab.c
+1
-0
No files found.
include/mruby/compile.h
View file @
a1795525
...
...
@@ -31,6 +31,7 @@ typedef struct mrbc_context {
mrb_bool
no_exec
:
1
;
mrb_bool
keep_lv
:
1
;
mrb_bool
no_optimize
:
1
;
mrb_bool
no_ext_ops
:
1
;
const
struct
RProc
*
upper
;
size_t
parser_nerr
;
...
...
@@ -155,6 +156,7 @@ struct mrb_parser_state {
mrb_bool
no_optimize
:
1
;
mrb_bool
capture_errors
:
1
;
mrb_bool
no_ext_ops
:
1
;
const
struct
RProc
*
upper
;
struct
mrb_parser_message
error_buffer
[
10
];
struct
mrb_parser_message
warn_buffer
[
10
];
...
...
mrbgems/mruby-bin-mrbc/tools/mrbc/mrbc.c
View file @
a1795525
...
...
@@ -24,6 +24,7 @@ struct mrbc_args {
mrb_bool
check_syntax
:
1
;
mrb_bool
verbose
:
1
;
mrb_bool
remove_lv
:
1
;
mrb_bool
no_ext_ops
:
1
;
uint8_t
flags
:
4
;
};
...
...
@@ -40,6 +41,7 @@ usage(const char *name)
"-S dump C struct (requires -B)"
,
"-s define <symbol> as static variable"
,
"--remove-lv remove local variables"
,
"--no-ext-ops prohibit using OP_EXTs"
,
"--verbose run at verbose mode"
,
"--version print the version"
,
"--copyright print the copyright"
,
...
...
@@ -163,6 +165,10 @@ parse_args(mrb_state *mrb, int argc, char **argv, struct mrbc_args *args)
args
->
remove_lv
=
TRUE
;
break
;
}
else
if
(
strcmp
(
argv
[
i
]
+
2
,
"no-ext-ops"
)
==
0
)
{
args
->
no_ext_ops
=
TRUE
;
break
;
}
return
-
1
;
default:
return
i
;
...
...
@@ -217,6 +223,7 @@ load_file(mrb_state *mrb, struct mrbc_args *args)
if
(
args
->
verbose
)
c
->
dump_result
=
TRUE
;
c
->
no_exec
=
TRUE
;
c
->
no_ext_ops
=
args
->
no_ext_ops
;
if
(
input
[
0
]
==
'-'
&&
input
[
1
]
==
'\0'
)
{
infile
=
stdin
;
}
...
...
mrbgems/mruby-compiler/core/codegen.c
View file @
a1795525
...
...
@@ -167,6 +167,14 @@ codegen_realloc(codegen_scope *s, void *p, size_t len)
return
p
;
}
static
void
check_no_ext_ops
(
codegen_scope
*
s
,
uint16_t
a
,
uint16_t
b
)
{
if
(
s
->
parser
->
no_ext_ops
&&
(
a
|
b
)
>
0xff
)
{
codegen_error
(
s
,
"need OP_EXTs instruction (currently OP_EXTs are prohibited)"
);
}
}
static
int
new_label
(
codegen_scope
*
s
)
{
...
...
@@ -235,6 +243,7 @@ static void
genop_1
(
codegen_scope
*
s
,
mrb_code
i
,
uint16_t
a
)
{
s
->
lastpc
=
s
->
pc
;
check_no_ext_ops
(
s
,
a
,
0
);
if
(
a
>
0xff
)
{
gen_B
(
s
,
OP_EXT1
);
gen_B
(
s
,
i
);
...
...
@@ -250,6 +259,7 @@ static void
genop_2
(
codegen_scope
*
s
,
mrb_code
i
,
uint16_t
a
,
uint16_t
b
)
{
s
->
lastpc
=
s
->
pc
;
check_no_ext_ops
(
s
,
a
,
b
);
if
(
a
>
0xff
&&
b
>
0xff
)
{
gen_B
(
s
,
OP_EXT3
);
gen_B
(
s
,
i
);
...
...
@@ -555,6 +565,7 @@ genjmp2(codegen_scope *s, mrb_code i, uint16_t a, uint32_t pc, int val)
}
if
(
a
>
0xff
)
{
check_no_ext_ops
(
s
,
a
,
0
);
gen_B
(
s
,
OP_EXT1
);
genop_0
(
s
,
i
);
gen_S
(
s
,
a
);
...
...
mrbgems/mruby-compiler/core/parse.y
View file @
a1795525
...
...
@@ -6569,6 +6569,7 @@ parser_init_cxt(parser_state *p, mrbc_context *cxt)
}
p->capture_errors = cxt->capture_errors;
p->no_optimize = cxt->no_optimize;
p->no_ext_ops = cxt->no_ext_ops;
p->upper = cxt->upper;
if (cxt->partial_hook) {
p->cxt = cxt;
...
...
mrbgems/mruby-compiler/core/y.tab.c
View file @
a1795525
...
...
@@ -12796,6 +12796,7 @@ parser_init_cxt(parser_state *p, mrbc_context *cxt)
}
p->capture_errors = cxt->capture_errors;
p->no_optimize = cxt->no_optimize;
p->no_ext_ops = cxt->no_ext_ops;
p->upper = cxt->upper;
if (cxt->partial_hook) {
p->cxt = cxt;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment