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();")
# `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
- return new_var(mtype)
+ res = new_var(mtype)
+
+ self.current_node = old
+ return res
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)
end
else if cname == "NativeString" then
if pname == "[]" then
- v.ret(v.new_expr("(uint32_t)(unsigned char){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]};")
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