prohibit overriding vm procs

This commit is contained in:
Yuichi Nishiwaki 2016-03-03 21:41:29 +09:00
parent e4bf1a14ab
commit 86c68b1769
1 changed files with 7 additions and 0 deletions

View File

@ -835,8 +835,15 @@ codegen_set(pic_state *pic, codegen_context *cxt, pic_value obj, bool tailpos)
type = pic_list_ref(pic, var, 0);
if (EQ(type, "gref")) {
pic_value name;
size_t i;
name = pic_list_ref(pic, var, 1);
for (i = 0; i < sizeof pic_vm_proc / sizeof pic_vm_proc[0]; ++i) {
if (EQ(name, pic_vm_proc[i].name))
pic_error(pic, "tried to override built-in procedure", 1, name);
}
emit_i(pic, cxt, OP_GSET, index_global(pic, cxt, name));
emit_ret(pic, cxt, tailpos);
}