private import utils
redef class ToolContext
- readable writable attr _global: Bool = false
- readable writable attr _compdir: String
- readable writable attr _clibdir: String
- readable writable attr _bindir: String
- readable writable attr _output_file: String
+ readable writable attr _global: Bool = false
+ readable writable attr _compdir: nullable String = null
+ readable writable attr _clibdir: nullable String = null
+ readable writable attr _bindir: nullable String = null
+ readable writable attr _output_file: nullable String = null
readable writable attr _boost: Bool = false
readable writable attr _no_cc: Bool = false
- readable writable attr _ext_prefix: String
+ readable writable attr _ext_prefix: String = ""
end
# Class used to generate files.
redef class MMLocalClass
# Cached primitive_info result
- attr _primitive_info_cache: PrimitiveInfo
+ attr _primitive_info_cache: nullable PrimitiveInfo = null
# If primitive_info result cached?
attr _primitive_info_b: Bool = false
# Return the primitive information of the class.
# Return null if the class is not primitive
# FIXME: Only here since there is no universal type yet
- meth primitive_info: PrimitiveInfo
+ meth primitive_info: nullable PrimitiveInfo
do
if _primitive_info_b == true then return _primitive_info_cache
var cnames = ["bigint", "char", "int", "float", "char *", "val_t *", "void *"]
for i in [0..pnames.length[ do
var n = pnames[i].to_symbol
- var pi = new PrimitiveInfo
- pi.name = n
- pi.tagged = tagged[i]
- pi.cname = cnames[i]
+ var pi = new PrimitiveInfo(n, tagged[i], cnames[i])
res[n] = pi
end
return res
# Information about a primitive class
class PrimitiveInfo
# The name of the class
- readable writable attr _name: Symbol
+ readable attr _name: Symbol
# Is the class tagged (aka not boxed)
- readable writable attr _tagged: Bool
+ readable attr _tagged: Bool
# The corresponding c type for the primitive value
- readable writable attr _cname: String
+ readable attr _cname: String
- private init do end
+ private init(n: Symbol, t: Bool, c: String)
+ do
+ _name = n
+ _tagged = t
+ _cname = c
+ end
end
redef class MMType
redef class MMLocalProperty
# Cacher result of cname
- attr _cname_cache: String
+ attr _cname_cache: nullable String
# The mangled name of the method
meth cname: String
do
- if _cname_cache == null then
- _cname_cache = cmangle(module.name, local_class.name, name)
+ var cname = _cname_cache
+ if cname == null then
+ cname = cmangle(module.name, local_class.name, name)
+ _cname_cache = cname
end
- return _cname_cache
+ return cname
end
# C macro used to get the function for the call of a super property