nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sep_comp: remove unrobust SeparateRuntimeFunction::arguments attribute
[nit.git]
/
src
/
compiler
/
separate_compiler.nit
diff --git
a/src/compiler/separate_compiler.nit
b/src/compiler/separate_compiler.nit
index
085a36d
..
95ceece
100644
(file)
--- a/
src/compiler/separate_compiler.nit
+++ b/
src/compiler/separate_compiler.nit
@@
-252,7
+252,7
@@
class SeparateCompiler
do
# Collect all bas box class
# FIXME: this is not completely fine with a separate compilation scheme
do
# Collect all bas box class
# FIXME: this is not completely fine with a separate compilation scheme
- for classname in ["Int", "Bool", "Char", "Float", "NativeString", "Pointer"] do
+ for classname in ["Int", "Bool", "Byte", "Char", "Float", "NativeString", "Pointer"] do
var classes = self.mainmodule.model.get_mclasses_by_name(classname)
if classes == null then continue
assert classes.length == 1 else print classes.join(", ")
var classes = self.mainmodule.model.get_mclasses_by_name(classname)
if classes == null then continue
assert classes.length == 1 else print classes.join(", ")
@@
-625,6
+625,7
@@
class SeparateCompiler
for cd in mmodule.mclassdefs do
for pd in cd.mpropdefs do
if not pd isa MMethodDef then continue
for cd in mmodule.mclassdefs do
for pd in cd.mpropdefs do
if not pd isa MMethodDef then continue
+ if pd.msignature == null then continue # Skip broken method
var rta = runtime_type_analysis
if modelbuilder.toolcontext.opt_skip_dead_methods.value and rta != null and not rta.live_methoddefs.has(pd) then continue
#print "compile {pd} @ {cd} @ {mmodule}"
var rta = runtime_type_analysis
if modelbuilder.toolcontext.opt_skip_dead_methods.value and rta != null and not rta.live_methoddefs.has(pd) then continue
#print "compile {pd} @ {cd} @ {mmodule}"
@@
-768,7
+769,8
@@
class SeparateCompiler
end
v.add_decl("\},")
else
end
v.add_decl("\},")
else
- v.add_decl("0, \{\}, /*DEAD TYPE*/")
+ # Use -1 to indicate dead type, the info is used by --hardening
+ v.add_decl("-1, \{\}, /*DEAD TYPE*/")
end
v.add_decl("\};")
end
end
v.add_decl("\};")
end
@@
-1036,7
+1038,7
@@
class SeparateCompiler
v.add("if({t} == NULL) \{")
v.add_abort("type null")
v.add("\}")
v.add("if({t} == NULL) \{")
v.add_abort("type null")
v.add("\}")
- v.add("if({t}->table_size == 0) \{")
+ v.add("if({t}->table_size < 0) \{")
v.add("PRINT_ERROR(\"Insantiation of a dead type: %s\\n\", {t}->name);")
v.add_abort("type dead")
v.add("\}")
v.add("PRINT_ERROR(\"Insantiation of a dead type: %s\\n\", {t}->name);")
v.add_abort("type dead")
v.add("\}")
@@
-1192,7
+1194,7
@@
class SeparateCompilerVisitor
if mtype.name == "Int" then
return self.new_expr("(long)({value})>>2", mtype)
else if mtype.name == "Char" then
if mtype.name == "Int" then
return self.new_expr("(long)({value})>>2", mtype)
else if mtype.name == "Char" then
- return self.new_expr("(char)((long)({value})>>2)", mtype)
+ return self.new_expr("(uint32_t)((long)({value})>>2)", mtype)
else if mtype.name == "Bool" then
return self.new_expr("(short int)((long)({value})>>2)", mtype)
else
else if mtype.name == "Bool" then
return self.new_expr("(short int)((long)({value})>>2)", mtype)
else
@@
-2207,9
+2209,6
@@
class SeparateRuntimeFunction
# The C type for the function pointer.
var c_funptrtype: String is lazy do return "{c_ret}(*){c_sig}"
# The C type for the function pointer.
var c_funptrtype: String is lazy do return "{c_ret}(*){c_sig}"
- # The arguments, as generated by `compile_to_c`
- private var arguments: Array[RuntimeVariable] is noinit
-
redef fun compile_to_c(compiler)
do
var mmethoddef = self.mmethoddef
redef fun compile_to_c(compiler)
do
var mmethoddef = self.mmethoddef
@@
-2246,7
+2245,6
@@
class SeparateRuntimeFunction
comment.append(": {ret}")
end
compiler.provide_declaration(self.c_name, "{sig};")
comment.append(": {ret}")
end
compiler.provide_declaration(self.c_name, "{sig};")
- self.arguments = arguments.to_a
v.add_decl("/* method {self} for {comment} */")
v.add_decl("{sig} \{")
v.add_decl("/* method {self} for {comment} */")
v.add_decl("{sig} \{")
@@
-2279,8
+2277,10
@@
class SeparateRuntimeFunction
fun compile_trampolines(compiler: SeparateCompiler)
do
var recv = self.mmethoddef.mclassdef.bound_mtype
fun compile_trampolines(compiler: SeparateCompiler)
do
var recv = self.mmethoddef.mclassdef.bound_mtype
- var selfvar = arguments.first
+ var selfvar = new RuntimeVariable("self", called_recv, recv)
var ret = called_signature.return_mtype
var ret = called_signature.return_mtype
+ var arguments = ["self"]
+ for i in [0..called_signature.arity[ do arguments.add "p{i}"
if mmethoddef.is_intro and not recv.is_c_primitive then
var m = mmethoddef.mproperty
if mmethoddef.is_intro and not recv.is_c_primitive then
var m = mmethoddef.mproperty