nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge: Simplify management of primitive types
[nit.git]
/
src
/
compiler
/
separate_compiler.nit
diff --git
a/src/compiler/separate_compiler.nit
b/src/compiler/separate_compiler.nit
index
93508a9
..
4d26aa3
100644
(file)
--- a/
src/compiler/separate_compiler.nit
+++ b/
src/compiler/separate_compiler.nit
@@
-268,7
+268,7
@@
class SeparateCompiler
if mclass.mclass_type.ctype_extern == "val*" then
return 0
else if mclass.kind == extern_kind and mclass.name != "NativeString" then
if mclass.mclass_type.ctype_extern == "val*" then
return 0
else if mclass.kind == extern_kind and mclass.name != "NativeString" then
- return self.box_kinds[self.mainmodule.get_primitive_class("Pointer")]
+ return self.box_kinds[self.mainmodule.pointer_type.mclass]
else
return self.box_kinds[mclass]
end
else
return self.box_kinds[mclass]
end
@@
-466,7
+466,7
@@
class SeparateCompiler
type_tables = build_type_tables(poset)
# VT and FT are stored with other unresolved types in the big resolution_tables
type_tables = build_type_tables(poset)
# VT and FT are stored with other unresolved types in the big resolution_tables
- self.compile_resolution_tables(live_types)
+ self.compute_resolution_tables(live_types)
return poset
end
return poset
end
@@
-527,9
+527,8
@@
class SeparateCompiler
return tables
end
return tables
end
- protected fun compile_resolution_tables(mtypes: Set[MType]) do
- # resolution_tables is used to perform a type resolution at runtime in O(1)
-
+ # resolution_tables is used to perform a type resolution at runtime in O(1)
+ private fun compute_resolution_tables(mtypes: Set[MType]) do
# During the visit of the body of classes, live_unresolved_types are collected
# and associated to
# Collect all live_unresolved_types (visited in the body of classes)
# During the visit of the body of classes, live_unresolved_types are collected
# and associated to
# Collect all live_unresolved_types (visited in the body of classes)
@@
-1188,7
+1187,7
@@
class SeparateCompilerVisitor
var res = self.new_var(mtype)
if compiler.runtime_type_analysis != null and not compiler.runtime_type_analysis.live_types.has(valtype) then
self.add("/*no autobox from {value.mtype} to {mtype}: {value.mtype} is not live! */")
var res = self.new_var(mtype)
if compiler.runtime_type_analysis != null and not compiler.runtime_type_analysis.live_types.has(valtype) then
self.add("/*no autobox from {value.mtype} to {mtype}: {value.mtype} is not live! */")
- self.add("PRINT_ERROR(\"Dead code executed!\\n\"); show_backtrace(1);")
+ self.add("PRINT_ERROR(\"Dead code executed!\\n\"); fatal_exit(1);")
return res
end
self.require_declaration("BOX_{valtype.c_name}")
return res
end
self.require_declaration("BOX_{valtype.c_name}")
@@
-1202,7
+1201,7
@@
class SeparateCompilerVisitor
# Bad things will appen!
var res = self.new_var(mtype)
self.add("/* {res} left unintialized (cannot convert {value.mtype} to {mtype}) */")
# Bad things will appen!
var res = self.new_var(mtype)
self.add("/* {res} left unintialized (cannot convert {value.mtype} to {mtype}) */")
- self.add("PRINT_ERROR(\"Cast error: Cannot cast %s to %s.\\n\", \"{value.mtype}\", \"{mtype}\"); show_backtrace(1);")
+ self.add("PRINT_ERROR(\"Cast error: Cannot cast %s to %s.\\n\", \"{value.mtype}\", \"{mtype}\"); fatal_exit(1);")
return res
end
end
return res
end
end
@@
-1228,7
+1227,7
@@
class SeparateCompilerVisitor
var res = self.new_var(mtype)
if compiler.runtime_type_analysis != null and not compiler.runtime_type_analysis.live_types.has(value.mtype.as(MClassType)) then
self.add("/*no boxing of {value.mtype}: {value.mtype} is not live! */")
var res = self.new_var(mtype)
if compiler.runtime_type_analysis != null and not compiler.runtime_type_analysis.live_types.has(value.mtype.as(MClassType)) then
self.add("/*no boxing of {value.mtype}: {value.mtype} is not live! */")
- self.add("PRINT_ERROR(\"Dead code executed!\\n\"); show_backtrace(1);")
+ self.add("PRINT_ERROR(\"Dead code executed!\\n\"); fatal_exit(1);")
return res
end
self.require_declaration("BOX_{valtype.c_name}")
return res
end
self.require_declaration("BOX_{valtype.c_name}")
@@
-1788,7
+1787,7
@@
class SeparateCompilerVisitor
self.add("count_type_test_resolved_{tag}++;")
end
else
self.add("count_type_test_resolved_{tag}++;")
end
else
- self.add("PRINT_ERROR(\"NOT YET IMPLEMENTED: type_test(%s, {mtype}).\\n\", \"{value.inspect}\"); show_backtrace(1);")
+ self.add("PRINT_ERROR(\"NOT YET IMPLEMENTED: type_test(%s, {mtype}).\\n\", \"{value.inspect}\"); fatal_exit(1);")
end
# check color is in table
end
# check color is in table
@@
-1985,8
+1984,8
@@
class SeparateCompilerVisitor
redef fun array_instance(array, elttype)
do
redef fun array_instance(array, elttype)
do
- var nclass = self.get_class("NativeArray")
- var arrayclass = self.get_class("Array")
+ var nclass = mmodule.native_array_class
+ var arrayclass = mmodule.array_class
var arraytype = arrayclass.get_mtype([elttype])
var res = self.init_instance(arraytype)
self.add("\{ /* {res} = array_instance Array[{elttype}] */")
var arraytype = arrayclass.get_mtype([elttype])
var res = self.init_instance(arraytype)
self.add("\{ /* {res} = array_instance Array[{elttype}] */")
@@
-2003,7
+2002,7
@@
class SeparateCompilerVisitor
redef fun native_array_instance(elttype: MType, length: RuntimeVariable): RuntimeVariable
do
redef fun native_array_instance(elttype: MType, length: RuntimeVariable): RuntimeVariable
do
- var mtype = self.get_class("NativeArray").get_mtype([elttype])
+ var mtype = mmodule.native_array_type(elttype)
self.require_declaration("NEW_{mtype.mclass.c_name}")
assert mtype isa MGenericType
var compiler = self.compiler
self.require_declaration("NEW_{mtype.mclass.c_name}")
assert mtype isa MGenericType
var compiler = self.compiler
@@
-2023,7
+2022,7
@@
class SeparateCompilerVisitor
redef fun native_array_def(pname, ret_type, arguments)
do
var elttype = arguments.first.mtype
redef fun native_array_def(pname, ret_type, arguments)
do
var elttype = arguments.first.mtype
- var nclass = self.get_class("NativeArray")
+ var nclass = mmodule.native_array_class
var recv = "((struct instance_{nclass.c_name}*){arguments[0]})->values"
if pname == "[]" then
# Because the objects are boxed, return the box to avoid unnecessary (or broken) unboxing/reboxing
var recv = "((struct instance_{nclass.c_name}*){arguments[0]})->values"
if pname == "[]" then
# Because the objects are boxed, return the box to avoid unnecessary (or broken) unboxing/reboxing
@@
-2044,14
+2043,6
@@
class SeparateCompilerVisitor
end
end
end
end
- redef fun calloc_array(ret_type, arguments)
- do
- var mclass = self.get_class("ArrayCapable")
- var ft = mclass.mparameters.first
- var res = self.native_array_instance(ft, arguments[1])
- self.ret(res)
- end
-
fun link_unresolved_type(mclassdef: MClassDef, mtype: MType) do
assert mtype.need_anchor
var compiler = self.compiler
fun link_unresolved_type(mclassdef: MClassDef, mtype: MType) do
assert mtype.need_anchor
var compiler = self.compiler
@@
-2162,7
+2153,7
@@
class SeparateRuntimeFunction
for i in [0..called_signature.arity[ do
var mtype = called_signature.mparameters[i].mtype
if i == called_signature.vararg_rank then
for i in [0..called_signature.arity[ do
var mtype = called_signature.mparameters[i].mtype
if i == called_signature.vararg_rank then
- mtype = mmethoddef.mclassdef.mmodule.get_primitive_class("Array").get_mtype([mtype])
+ mtype = mmethoddef.mclassdef.mmodule.array_type(mtype)
end
sig.append(", {mtype.ctype} p{i}")
end
end
sig.append(", {mtype.ctype} p{i}")
end
@@
-2201,7
+2192,7
@@
class SeparateRuntimeFunction
for i in [0..msignature.arity[ do
var mtype = msignature.mparameters[i].mtype
if i == msignature.vararg_rank then
for i in [0..msignature.arity[ do
var mtype = msignature.mparameters[i].mtype
if i == msignature.vararg_rank then
- mtype = v.get_class("Array").get_mtype([mtype])
+ mtype = v.mmodule.array_type(mtype)
end
comment.append(", {mtype}")
var argvar = new RuntimeVariable("p{i}", mtype, mtype)
end
comment.append(", {mtype}")
var argvar = new RuntimeVariable("p{i}", mtype, mtype)