Wrap all the C++-generated code in a namespace.
Avoids collisions with the global functions defined by the DAL.
This commit is contained in:
Родитель
bd63ab2283
Коммит
ab9c7b8559
|
@ -73,17 +73,21 @@ module TDev {
|
||||||
var compiled = everything.map((a: J.JApp, i: number) => compile1(everything, resolveMap[i], a));
|
var compiled = everything.map((a: J.JApp, i: number) => compile1(everything, resolveMap[i], a));
|
||||||
return Promise.as(
|
return Promise.as(
|
||||||
compiled.map(x => x.prelude)
|
compiled.map(x => x.prelude)
|
||||||
|
.concat(["namespace touch_develop {"])
|
||||||
.concat(compiled.map(x => x.tPrototypes))
|
.concat(compiled.map(x => x.tPrototypes))
|
||||||
.concat(compiled.map(x => x.tCode))
|
.concat(compiled.map(x => x.tCode))
|
||||||
.concat(compiled.map(x => x.prototypes))
|
.concat(compiled.map(x => x.prototypes))
|
||||||
.concat(compiled.map(x => x.code))
|
.concat(compiled.map(x => x.code))
|
||||||
|
.concat(["}"])
|
||||||
.filter(x => x != "")
|
.filter(x => x != "")
|
||||||
.join("\n") +
|
.join("\n") + "\n" +
|
||||||
(a.isLibrary
|
(a.isLibrary
|
||||||
? "\nvoid app_main() {\n"+
|
? "\nvoid app_main() {\n"+
|
||||||
" uBit.display.scroll(\"Error: trying to run a library\");\n"+
|
" uBit.display.scroll(\"Error: trying to run a library\");\n"+
|
||||||
"}\n"
|
"}\n"
|
||||||
: "")
|
: "\nvoid app_main() {\n"+
|
||||||
|
" touch_develop::app_main();\n"+
|
||||||
|
"}\n")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -506,6 +506,7 @@ module TDev {
|
||||||
// This function runs over all declarations. After execution, the three
|
// This function runs over all declarations. After execution, the three
|
||||||
// member fields [prelude], [prototypes] and [code] are filled accordingly.
|
// member fields [prelude], [prototypes] and [code] are filled accordingly.
|
||||||
public visitApp(e: EmitterEnv, decls: J.JDecl[]) {
|
public visitApp(e: EmitterEnv, decls: J.JDecl[]) {
|
||||||
|
e = indent(e);
|
||||||
if (this.libName)
|
if (this.libName)
|
||||||
e = indent(e);
|
e = indent(e);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче