-D profileKiss to see each file's build() time
This commit is contained in:
@@ -172,23 +172,30 @@ class AsyncEmbeddedScript {
|
|||||||
scriptFile = Path.join([loadingDirectory, scriptFile]);
|
scriptFile = Path.join([loadingDirectory, scriptFile]);
|
||||||
k.fieldList = [];
|
k.fieldList = [];
|
||||||
Kiss._try(() -> {
|
Kiss._try(() -> {
|
||||||
Reader.readAndProcess(Stream.fromFile(scriptFile), k, (nextExp) -> {
|
#if profileKiss
|
||||||
var exprString = Reader.toString(nextExp.def);
|
haxe.Timer.measure(() -> {
|
||||||
var expr = Kiss.readerExpToHaxeExpr(nextExp, k);
|
trace(scriptFile);
|
||||||
|
#end
|
||||||
|
Reader.readAndProcess(Stream.fromFile(scriptFile), k, (nextExp) -> {
|
||||||
|
var exprString = Reader.toString(nextExp.def);
|
||||||
|
var expr = Kiss.readerExpToHaxeExpr(nextExp, k);
|
||||||
|
|
||||||
#if debug
|
#if debug
|
||||||
expr = macro { Prelude.print($v{exprString}); $expr; };
|
expr = macro { Prelude.print($v{exprString}); $expr; };
|
||||||
#end
|
#end
|
||||||
if (expr != null) {
|
if (expr != null) {
|
||||||
commandList.push(macro function(self, cc) {
|
commandList.push(macro function(self, cc) {
|
||||||
$expr;
|
$expr;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// This return is essential for type unification of concat() and push() above... ugh.
|
// This return is essential for type unification of concat() and push() above... ugh.
|
||||||
return;
|
return;
|
||||||
|
});
|
||||||
|
null;
|
||||||
|
#if profileKiss
|
||||||
});
|
});
|
||||||
null;
|
#end
|
||||||
});
|
});
|
||||||
|
|
||||||
classFields = classFields.concat(k.fieldList);
|
classFields = classFields.concat(k.fieldList);
|
||||||
|
@@ -64,23 +64,30 @@ class EmbeddedScript {
|
|||||||
scriptFile = Path.join([loadingDirectory, scriptFile]);
|
scriptFile = Path.join([loadingDirectory, scriptFile]);
|
||||||
|
|
||||||
Kiss._try(() -> {
|
Kiss._try(() -> {
|
||||||
Reader.readAndProcess(Stream.fromFile(scriptFile), k, (nextExp) -> {
|
#if profileKiss
|
||||||
var expr = Kiss.readerExpToHaxeExpr(nextExp, k);
|
haxe.Timer.measure(() -> {
|
||||||
|
trace(scriptFile);
|
||||||
|
#end
|
||||||
|
Reader.readAndProcess(Stream.fromFile(scriptFile), k, (nextExp) -> {
|
||||||
|
var expr = Kiss.readerExpToHaxeExpr(nextExp, k);
|
||||||
|
|
||||||
if (expr != null) {
|
if (expr != null) {
|
||||||
commandList.push(macro function(self) {
|
commandList.push(macro function(self) {
|
||||||
$expr;
|
$expr;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// This return is essential for type unification of concat() and push() above... ugh.
|
// This return is essential for type unification of concat() and push() above... ugh.
|
||||||
return;
|
return;
|
||||||
// TODO also allow label setting and multiple commands coming from the same expr?
|
// TODO also allow label setting and multiple commands coming from the same expr?
|
||||||
// Multiple things could come from the same expr by returning begin, or a call to a function that does more stuff
|
// Multiple things could come from the same expr by returning begin, or a call to a function that does more stuff
|
||||||
// i.e. knot declarations need to end the previous knot, and BELOW that set a label for the new one, then increment the read count
|
// i.e. knot declarations need to end the previous knot, and BELOW that set a label for the new one, then increment the read count
|
||||||
// TODO test await
|
// TODO test await
|
||||||
|
});
|
||||||
|
null;
|
||||||
|
#if profileKiss
|
||||||
});
|
});
|
||||||
null;
|
#end
|
||||||
});
|
});
|
||||||
|
|
||||||
classFields.push({
|
classFields.push({
|
||||||
|
@@ -164,6 +164,7 @@ class Kiss {
|
|||||||
Build macro: add fields to a class from a corresponding .kiss file
|
Build macro: add fields to a class from a corresponding .kiss file
|
||||||
**/
|
**/
|
||||||
public static function build(?kissFile:String, ?k:KissState, useClassFields = true):Array<Field> {
|
public static function build(?kissFile:String, ?k:KissState, useClassFields = true):Array<Field> {
|
||||||
|
|
||||||
var classPath = Context.getPosInfos(Context.currentPos()).file;
|
var classPath = Context.getPosInfos(Context.currentPos()).file;
|
||||||
// (load... ) relative to the original file
|
// (load... ) relative to the original file
|
||||||
var loadingDirectory = Path.directory(classPath);
|
var loadingDirectory = Path.directory(classPath);
|
||||||
@@ -173,42 +174,49 @@ class Kiss {
|
|||||||
//trace('kiss build $kissFile');
|
//trace('kiss build $kissFile');
|
||||||
|
|
||||||
return _try(() -> {
|
return _try(() -> {
|
||||||
if (k == null)
|
#if profileKiss
|
||||||
k = defaultKissState();
|
haxe.Timer.measure(() -> {
|
||||||
|
trace(kissFile);
|
||||||
|
#end
|
||||||
|
if (k == null)
|
||||||
|
k = defaultKissState();
|
||||||
|
|
||||||
if (useClassFields) {
|
if (useClassFields) {
|
||||||
k.fieldList = Context.getBuildFields();
|
k.fieldList = Context.getBuildFields();
|
||||||
for (field in k.fieldList) {
|
for (field in k.fieldList) {
|
||||||
k.fieldDict[field.name] = field;
|
k.fieldDict[field.name] = field;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
k.loadingDirectory = loadingDirectory;
|
||||||
k.loadingDirectory = loadingDirectory;
|
|
||||||
|
|
||||||
var topLevelBegin = load(kissFile, k);
|
var topLevelBegin = load(kissFile, k);
|
||||||
|
|
||||||
if (topLevelBegin != null) {
|
if (topLevelBegin != null) {
|
||||||
// If no main function is defined manually, Kiss expressions at the top of a file will be put in a main function.
|
// If no main function is defined manually, Kiss expressions at the top of a file will be put in a main function.
|
||||||
// If a main function IS defined, this will result in an error
|
// If a main function IS defined, this will result in an error
|
||||||
if (k.fieldDict.exists("main")) {
|
if (k.fieldDict.exists("main")) {
|
||||||
throw CompileError.fromExp(topLevelBegin, '$kissFile has expressions outside of field definitions, but already defines its own main function.');
|
throw CompileError.fromExp(topLevelBegin, '$kissFile has expressions outside of field definitions, but already defines its own main function.');
|
||||||
|
}
|
||||||
|
var b = topLevelBegin.expBuilder();
|
||||||
|
// This doesn't need to be added to the fieldDict because all code generation is done
|
||||||
|
k.fieldList.push({
|
||||||
|
name: "main",
|
||||||
|
access: [AStatic],
|
||||||
|
kind: FFun(Helpers.makeFunction(
|
||||||
|
b.symbol("main"),
|
||||||
|
false,
|
||||||
|
b.list([]),
|
||||||
|
[topLevelBegin],
|
||||||
|
k,
|
||||||
|
"function")),
|
||||||
|
pos: topLevelBegin.macroPos()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
var b = topLevelBegin.expBuilder();
|
|
||||||
// This doesn't need to be added to the fieldDict because all code generation is done
|
|
||||||
k.fieldList.push({
|
|
||||||
name: "main",
|
|
||||||
access: [AStatic],
|
|
||||||
kind: FFun(Helpers.makeFunction(
|
|
||||||
b.symbol("main"),
|
|
||||||
false,
|
|
||||||
b.list([]),
|
|
||||||
[topLevelBegin],
|
|
||||||
k,
|
|
||||||
"function")),
|
|
||||||
pos: topLevelBegin.macroPos()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
k.fieldList;
|
k.fieldList;
|
||||||
|
#if profileKiss
|
||||||
|
});
|
||||||
|
#end
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user