nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sep_comp: do not rely on RTA in autobox
[nit.git]
/
src
/
compiler
/
abstract_compiler.nit
diff --git
a/src/compiler/abstract_compiler.nit
b/src/compiler/abstract_compiler.nit
index
c48aab9
..
9601c1d
100644
(file)
--- a/
src/compiler/abstract_compiler.nit
+++ b/
src/compiler/abstract_compiler.nit
@@
-842,7
+842,7
@@
extern void nitni_global_ref_decr( struct nitni_ref *ref );
v.add("signal(SIGINT, sig_handler);")
v.add("signal(SIGTERM, sig_handler);")
v.add("signal(SIGSEGV, sig_handler);")
v.add("signal(SIGINT, sig_handler);")
v.add("signal(SIGTERM, sig_handler);")
v.add("signal(SIGSEGV, sig_handler);")
- v.add("signal(SIGPIPE, sig_handler);")
+ v.add("signal(SIGPIPE, SIG_IGN);")
v.add("glob_argc = argc; glob_argv = argv;")
v.add("initialize_gc_option();")
v.add("glob_argc = argc; glob_argv = argv;")
v.add("initialize_gc_option();")
@@
-1696,18
+1696,27
@@
abstract class AbstractCompilerVisitor
# `mtype` is the expected return type, pass null if no specific type is expected.
fun expr(nexpr: AExpr, mtype: nullable MType): RuntimeVariable
do
# `mtype` is the expected return type, pass null if no specific type is expected.
fun expr(nexpr: AExpr, mtype: nullable MType): RuntimeVariable
do
- if nexpr.mtype == null then
+ var old = self.current_node
+ self.current_node = nexpr
+
+ var res = null
+ if nexpr.mtype != null then
+ res = nexpr.expr(self)
+ end
+
+ if res == null then
# Untyped expression.
# Might mean dead code or invalid code.
# so aborts
add_abort("FATAL: bad expression executed.")
# and return a placebo result to please the C compiler
if mtype == null then mtype = compiler.mainmodule.object_type
# Untyped expression.
# Might mean dead code or invalid code.
# so aborts
add_abort("FATAL: bad expression executed.")
# and return a placebo result to please the C compiler
if mtype == null then mtype = compiler.mainmodule.object_type
- return new_var(mtype)
+ res = new_var(mtype)
+
+ self.current_node = old
+ return res
end
end
- var old = self.current_node
- self.current_node = nexpr
- var res = nexpr.expr(self).as(not null)
+
if mtype != null then
mtype = self.anchor(mtype)
res = self.autobox(res, mtype)
if mtype != null then
mtype = self.anchor(mtype)
res = self.autobox(res, mtype)
@@
-1879,7
+1888,7
@@
redef class MClassType
else if mclass.name == "Byte" then
return "unsigned char"
else if mclass.name == "NativeString" then
else if mclass.name == "Byte" then
return "unsigned char"
else if mclass.name == "NativeString" then
- return "unsigned char*"
+ return "char*"
else if mclass.name == "NativeArray" then
return "val*"
else
else if mclass.name == "NativeArray" then
return "val*"
else
@@
-2323,7
+2332,7
@@
redef class AMethPropdef
end
else if cname == "NativeString" then
if pname == "[]" then
end
else if cname == "NativeString" then
if pname == "[]" then
- v.ret(v.new_expr("(uint32_t){arguments[0]}[{arguments[1]}]", ret.as(not null)))
+ v.ret(v.new_expr("(unsigned char)((int){arguments[0]}[{arguments[1]}])", ret.as(not null)))
return true
else if pname == "[]=" then
v.add("{arguments[0]}[{arguments[1]}]=(unsigned char){arguments[2]};")
return true
else if pname == "[]=" then
v.add("{arguments[0]}[{arguments[1]}]=(unsigned char){arguments[2]};")
@@
-2338,7
+2347,7
@@
redef class AMethPropdef
v.ret(v.new_expr("{arguments[0]} + {arguments[1]}", ret.as(not null)))
return true
else if pname == "new" then
v.ret(v.new_expr("{arguments[0]} + {arguments[1]}", ret.as(not null)))
return true
else if pname == "new" then
- v.ret(v.new_expr("(unsigned char*)nit_alloc({arguments[1]})", ret.as(not null)))
+ v.ret(v.new_expr("(char*)nit_alloc({arguments[1]})", ret.as(not null)))
return true
end
else if cname == "NativeArray" then
return true
end
else if cname == "NativeArray" then
@@
-2352,7
+2361,7
@@
redef class AMethPropdef
v.ret(v.new_expr("glob_sys", ret.as(not null)))
return true
else if pname == "calloc_string" then
v.ret(v.new_expr("glob_sys", ret.as(not null)))
return true
else if pname == "calloc_string" then
- v.ret(v.new_expr("(unsigned char*)nit_alloc({arguments[1]})", ret.as(not null)))
+ v.ret(v.new_expr("(char*)nit_alloc({arguments[1]})", ret.as(not null)))
return true
else if pname == "calloc_array" then
v.calloc_array(ret.as(not null), arguments)
return true
else if pname == "calloc_array" then
v.calloc_array(ret.as(not null), arguments)
@@
-3035,7
+3044,9
@@
redef class AIsaExpr
redef fun expr(v)
do
var i = v.expr(self.n_expr, null)
redef fun expr(v)
do
var i = v.expr(self.n_expr, null)
- return v.type_test(i, self.cast_type.as(not null), "isa")
+ var cast_type = self.cast_type
+ if cast_type == null then return null # no-no on broken node
+ return v.type_test(i, cast_type, "isa")
end
end
end
end