X-Git-Url: http://nitlanguage.org diff --git a/src/compiling/compiling_base.nit b/src/compiling/compiling_base.nit index 93ba9fe..3fcdf8d 100644 --- a/src/compiling/compiling_base.nit +++ b/src/compiling/compiling_base.nit @@ -21,15 +21,14 @@ import syntax private import utils redef class ToolContext - readable writable attr _global: Bool = false - readable writable attr _attr_sim: 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. @@ -87,20 +86,24 @@ class CompilerVisitor return out.join("\n") end - # The current module processed - readable writable attr _module: MMSrcModule + # The processed module + readable attr _module: MMSrcModule # Where instr and decl are stored readable writable attr _ctx: CContext = new CContext # The current indent lever - readable writable attr _indent_level: Int = 0 + readable writable attr _indent_level: Int = 0 - # The current ToolContext - readable writable attr _tc: ToolContext + # The ToolContext info + readable attr _tc: ToolContext # Create a new CompilerVisitor based on a module - init(module: MMSrcModule) do _module = module + init(module: MMSrcModule, tc: ToolContext) + do + _module = module + _tc = tc + end end # Where instr and decl are stored for a module @@ -136,13 +139,6 @@ redef class MMGlobalProperty do return "ATTR_{intro.cname}" end - - # C symbol refering the color of the global property - meth color_id: String - do - return "COLOR_{intro.cname}" - end - end redef class MMGlobalClass @@ -167,7 +163,7 @@ end 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 @@ -175,7 +171,7 @@ redef class MMLocalClass # 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 @@ -211,10 +207,7 @@ redef class MMLocalClass 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 @@ -224,15 +217,20 @@ end # 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 @@ -290,21 +288,17 @@ end 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 - end - - # C symbol refering the color of the super call of a super property - meth color_id_for_super: String - do - return "COLOR_SUPER_{cname}" + return cname end # C macro used to get the function for the call of a super property