pass kissFile and className to conditional compiler macros
This commit is contained in:
@@ -47,6 +47,7 @@ class AsyncEmbeddedScript {
|
|||||||
// trace('AsyncEmbeddedScript.build $dslHaxelib $dslFile $scriptFile');
|
// trace('AsyncEmbeddedScript.build $dslHaxelib $dslFile $scriptFile');
|
||||||
var k = Kiss.defaultKissState();
|
var k = Kiss.defaultKissState();
|
||||||
|
|
||||||
|
k.file = scriptFile;
|
||||||
var classPath = Context.getPosInfos(Context.currentPos()).file;
|
var classPath = Context.getPosInfos(Context.currentPos()).file;
|
||||||
var loadingDirectory = Path.directory(classPath);
|
var loadingDirectory = Path.directory(classPath);
|
||||||
var classFields = []; // Kiss.build() will already include Context.getBuildFields()
|
var classFields = []; // Kiss.build() will already include Context.getBuildFields()
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class EmbeddedScript {
|
|||||||
#if macro
|
#if macro
|
||||||
public static function build(dslFile:String, scriptFile:String):Array<Field> {
|
public static function build(dslFile:String, scriptFile:String):Array<Field> {
|
||||||
var k = Kiss.defaultKissState();
|
var k = Kiss.defaultKissState();
|
||||||
|
k.file = scriptFile;
|
||||||
|
|
||||||
var classPath = Context.getPosInfos(Context.currentPos()).file;
|
var classPath = Context.getPosInfos(Context.currentPos()).file;
|
||||||
var loadingDirectory = Path.directory(classPath);
|
var loadingDirectory = Path.directory(classPath);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ typedef ExprConversion = (ReaderExp) -> Expr;
|
|||||||
|
|
||||||
typedef KissState = {
|
typedef KissState = {
|
||||||
className:String,
|
className:String,
|
||||||
|
file:String,
|
||||||
readTable:ReadTable,
|
readTable:ReadTable,
|
||||||
startOfLineReadTable:ReadTable,
|
startOfLineReadTable:ReadTable,
|
||||||
fieldForms:Map<String, FieldFormFunction>,
|
fieldForms:Map<String, FieldFormFunction>,
|
||||||
@@ -51,6 +52,7 @@ class Kiss {
|
|||||||
|
|
||||||
var k = {
|
var k = {
|
||||||
className: className,
|
className: className,
|
||||||
|
file: "",
|
||||||
readTable: Reader.builtins(),
|
readTable: Reader.builtins(),
|
||||||
startOfLineReadTable: new ReadTable(),
|
startOfLineReadTable: new ReadTable(),
|
||||||
fieldForms: FieldForms.builtins(),
|
fieldForms: FieldForms.builtins(),
|
||||||
@@ -215,6 +217,8 @@ class Kiss {
|
|||||||
} else {
|
} else {
|
||||||
Path.join([loadingDirectory, kissFile]);
|
Path.join([loadingDirectory, kissFile]);
|
||||||
};
|
};
|
||||||
|
var previousFile = k.file;
|
||||||
|
k.file = fullPath;
|
||||||
|
|
||||||
if (k.loadedFiles.exists(fullPath)) {
|
if (k.loadedFiles.exists(fullPath)) {
|
||||||
return k.loadedFiles[fullPath];
|
return k.loadedFiles[fullPath];
|
||||||
@@ -268,6 +272,7 @@ class Kiss {
|
|||||||
null;
|
null;
|
||||||
}
|
}
|
||||||
k.loadedFiles[fullPath] = exp;
|
k.loadedFiles[fullPath] = exp;
|
||||||
|
k.file = previousFile;
|
||||||
return exp;
|
return exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,8 @@ class Macros {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function prepareForConditional(i:KissInterp, k:KissState) {
|
function prepareForConditional(i:KissInterp, k:KissState) {
|
||||||
|
i.variables.set("kissFile", k.file);
|
||||||
|
i.variables.set("className", k.className);
|
||||||
for (flag => value in Context.getDefines()) {
|
for (flag => value in Context.getDefines()) {
|
||||||
// Don't overwrite types that are put in all KissInterps, i.e. the kiss namespace
|
// Don't overwrite types that are put in all KissInterps, i.e. the kiss namespace
|
||||||
if (!i.variables.exists(flag)) {
|
if (!i.variables.exists(flag)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user