fun pretty_default: String
do
- if default_value != null then
- return " ({default_value})"
- end
+ var dv = default_value
+ if dv != null then return " ({dv})"
return ""
end
# Then execute the build.sh
fun compile_prog_to_c
do
- tc.compdir.mkdir
+ var compdir = tc.compdir.as(not null)
+ compdir.mkdir
var files = new Array[String]
var includes = new ArraySet[String]
files.add("$CLIBDIR/gc_static_objects_list.c")
tc.info("Generating C code",1)
for m in module.mhe.greaters_and_self do
- files.add("{tc.compdir}/{m.name}.{get_file_ending}.c")
+ files.add("{compdir}/{m.name}.{get_file_ending}.c")
tc.info("Generating C code for module: {m.name}",2)
m.compile_separate_module(self)
var native_name = m.location.file.strip_extension(".nit")
end
tc.info("Generating main, tables and makefile ...",1)
- files.add("{tc.compdir}/{module.name}._tables.c")
+ files.add("{compdir}/{module.name}._tables.c")
compile_main
- var fn = "{tc.compdir}/{module.name}._build.sh"
+ var fn = "{compdir}/{module.name}._build.sh"
var f = new OFStream.open(fn)
var verbose = ""
f.write("#!/bin/sh\n")
f.write("# This shell script is generated by NIT to compile the program {module.name}.\n")
- f.write("CLIBDIR=\"{tc.clibdir}\"\n")
- f.write("{tc.bindir}/gccx {verbose} -d {tc.compdir} -I $CLIBDIR {includes.join(" ")}")
+ f.write("CLIBDIR=\"{tc.clibdir.as(not null)}\"\n")
+ f.write("{tc.bindir.as(not null)}/gccx {verbose} -d {compdir} -I $CLIBDIR {includes.join(" ")}")
if tc.output_file != null then
- f.write(" -o {tc.output_file}")
+ f.write(" -o {tc.output_file.as(not null)}")
else if tc.ext_prefix.is_empty then
f.write(" -o {module.name}")
else
v.add_decl("#include <nit_common.h>")
compile_tables_to_c(v)
compile_main_part(v)
- var f = new OFStream.open("{tc.compdir}/{module.name}._tables.c")
+ var f = new OFStream.open("{tc.compdir.as(not null)}/{module.name}._tables.c")
f.write("/* This C file is generated by NIT to compile program {module.name}. */\n")
for m in module.mhe.greaters_and_self do
f.write("#include \"{m.name}.{get_file_ending}.h\"\n")
if native_name.file_exists then v.add_decl("#include <{native_name.basename("")}>")
declare_class_tables_to_c(v)
compile_mod_to_c(v)
- var f = new OFStream.open("{tc.compdir}/{name}.{program.get_file_ending}.h")
+ var f = new OFStream.open("{tc.compdir.as(not null)}/{name}.{program.get_file_ending}.h")
f.write("/* This C header file is generated by NIT to compile modules and programs that requires {name}. */\n")
f.write("#ifndef {name}{program.get_file_ending}\n")
f.write("#define {name}{program.get_file_ending}\n")
f.write("#endif\n")
f.close
- f = new OFStream.open("{tc.compdir}/{name}.{program.get_file_ending}.c")
+ f = new OFStream.open("{tc.compdir.as(not null)}/{name}.{program.get_file_ending}.c")
f.write("/* This C file is generated by NIT to compile module {name}. */\n")
f.write("#include \"{name}.{program.get_file_ending}.h\"\n")
for s in v.ctx.instrs do
end
s.append("({a.join(",")})")
end
- if _return_type != null then
- s.append(": {_return_type}")
- end
+ var rt = _return_type
+ if rt != null then s.append(": {rt}")
return s.to_s
end
end
redef fun to_s: String do
- if location == null then
+ var l = location
+ if l == null then
return text
else
- return "{location}: {text}"
+ return "{l}: {text}"
end
end
end
add("<a href=\"overview.html\"><b>Overview</b></a> <a href=\"index-1.html\"><b>Index</b></a> <a href=\"index.html\" target=\"_top\"><b>With Frames</b></a>\n")
add("</td></tr></table>")
add("Visibility: ")
+ var module = module
if (not inside_mode and not intrude_mode) or module == null then
add("<b>Public</b> ")
else
var ionce = new IOnce
var reg = v.expr(ionce, stype)
v.seq = ionce.body
- var ns = v.expr(new INative("BOX_NativeString(\"{_cstring}\")", null), v.visitor.type_nativestring)
- var ni = v.expr(new INative("TAG_Int({_cstring_length})", null), v.visitor.type_int)
+ var ns = v.expr(new INative("BOX_NativeString(\"{_cstring.as(not null)}\")", null), v.visitor.type_nativestring)
+ var ni = v.expr(new INative("TAG_Int({_cstring_length.as(not null)})", null), v.visitor.type_int)
var prop = v.visitor.get_method(stype, once "with_native".to_symbol)
var e = v.expr(new INew(stype, prop, [ns, ni]), stype)
v.add_assignment(reg, e)
var t0 = n_type.get_stype(v)
if t0 != null then t = t0 else return
else
- v.error(self, "Not yet implemented: Attribute definition {_prop.local_class}::{_prop} requires an explicit type.")
+ v.error(self, "Not yet implemented: Attribute definition {prop.local_class}::{prop} requires an explicit type.")
return
end
node = n
end
end
+ assert stype != null
for n in nodes do
- if not n.stype < stype.as(not null) then
+ if not n.stype < stype then
if node == null then
error(n, "Type error: no most general type. Got {n.stype} and {stype}.")
else
else if candidates.length > 0 then
var a = new Array[String]
for p in candidates do
- a.add("{p.full_name}{p.signature}")
+ a.add("{p.full_name}{p.signature.as(not null)}")
end
v.error(n, "Error: Conflicting default constructor to call for {c}: {a.join(", ")}.")
return null
else if false_candidates.length > 0 then
var a = new Array[String]
for p in false_candidates do
- a.add("{p.full_name}{p.signature}")
+ a.add("{p.full_name}{p.signature.as(not null)}")
end
v.error(n, "Error: there is no available compatible constrctor in {c}. Discarded candidates are {a.join(", ")}.")
return null
else if cla == prev_class then
v.error(self, "Error: Only one super constructor invocation of class {cla} is allowed.")
else
- var last_is_found = prev_class == null
for c in order do
if c == prev_class then
- last_is_found = true
+ prev_class = null
else if c == cla then
- if not last_is_found then
+ if prev_class != null then
v.error(self, "Error: Constructor of {c} must be invoked before constructor of {prev_class}")
end
esic.add(property)