Rename haxe macro withPos()
This commit is contained in:
@@ -6,7 +6,7 @@ import haxe.macro.Context;
|
|||||||
using StringTools;
|
using StringTools;
|
||||||
|
|
||||||
class Helpers {
|
class Helpers {
|
||||||
public static function withPos(e:ExprDef):Expr {
|
public static function withContextPos(e:ExprDef):Expr {
|
||||||
return {
|
return {
|
||||||
pos: Context.currentPos(),
|
pos: Context.currentPos(),
|
||||||
expr: e
|
expr: e
|
||||||
|
|||||||
@@ -64,9 +64,9 @@ class Macros {
|
|||||||
EFunction(FArrow, {
|
EFunction(FArrow, {
|
||||||
args: [],
|
args: [],
|
||||||
ret: null,
|
ret: null,
|
||||||
expr: EReturn(k.convert(callArg)).withPos()
|
expr: EReturn(k.convert(callArg)).withContextPos()
|
||||||
}).withPos()
|
}).withContextPos()
|
||||||
]).withPos();
|
]).withContextPos();
|
||||||
};
|
};
|
||||||
|
|
||||||
CallExp(Symbol("defun"), exps);
|
CallExp(Symbol("defun"), exps);
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class SpecialForms {
|
|||||||
case Symbol(name): name;
|
case Symbol(name): name;
|
||||||
default: throw 'first arg in (new [type] ...) should be a class to instantiate';
|
default: throw 'first arg in (new [type] ...) should be a class to instantiate';
|
||||||
};
|
};
|
||||||
ENew(Helpers.parseTypePath(classType), args.slice(1).map(convert)).withPos();
|
ENew(Helpers.parseTypePath(classType), args.slice(1).map(convert)).withContextPos();
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO special form for assignment
|
// TODO special form for assignment
|
||||||
@@ -77,7 +77,7 @@ class SpecialForms {
|
|||||||
throw '(let....) expression with bindings $bindingPairs needs a body';
|
throw '(let....) expression with bindings $bindingPairs needs a body';
|
||||||
}
|
}
|
||||||
|
|
||||||
EBlock([EVars(varDefs).withPos(), EBlock(body.map(convert)).withPos()]).withPos();
|
EBlock([EVars(varDefs).withContextPos(), EBlock(body.map(convert)).withContextPos()]).withContextPos();
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO special form for lambda
|
// TODO special form for lambda
|
||||||
@@ -100,7 +100,7 @@ class SpecialForms {
|
|||||||
ECheckType(convert(args[1]), switch (args[0]) {
|
ECheckType(convert(args[1]), switch (args[0]) {
|
||||||
case Symbol(type): Helpers.parseComplexType(type);
|
case Symbol(type): Helpers.parseComplexType(type);
|
||||||
default: throw 'first argument to (the... ) should be a valid type';
|
default: throw 'first argument to (the... ) should be a valid type';
|
||||||
}).withPos();
|
}).withContextPos();
|
||||||
};
|
};
|
||||||
|
|
||||||
map["try"] = (args:Array<ReaderExp>, convert:ExprConversion) -> {
|
map["try"] = (args:Array<ReaderExp>, convert:ExprConversion) -> {
|
||||||
@@ -129,14 +129,14 @@ class SpecialForms {
|
|||||||
throw 'expressions following the first expression in a (try... ) should all be (catch... ) expressions, but you used $catchKissExp';
|
throw 'expressions following the first expression in a (try... ) should all be (catch... ) expressions, but you used $catchKissExp';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]).withPos();
|
]).withContextPos();
|
||||||
};
|
};
|
||||||
|
|
||||||
map["throw"] = (args:Array<ReaderExp>, convert:ExprConversion) -> {
|
map["throw"] = (args:Array<ReaderExp>, convert:ExprConversion) -> {
|
||||||
if (args.length != 1) {
|
if (args.length != 1) {
|
||||||
throw 'throw expression should only throw one value, not: $args';
|
throw 'throw expression should only throw one value, not: $args';
|
||||||
}
|
}
|
||||||
EThrow(convert(args[0])).withPos();
|
EThrow(convert(args[0])).withContextPos();
|
||||||
};
|
};
|
||||||
|
|
||||||
map["<"] = foldComparison("_min");
|
map["<"] = foldComparison("_min");
|
||||||
@@ -154,7 +154,7 @@ class SpecialForms {
|
|||||||
var thenExp = convert(args[1]);
|
var thenExp = convert(args[1]);
|
||||||
var elseExp = if (args.length > 2) convert(args[2]) else null;
|
var elseExp = if (args.length > 2) convert(args[2]) else null;
|
||||||
|
|
||||||
EIf(condition, thenExp, elseExp).withPos();
|
EIf(condition, thenExp, elseExp).withContextPos();
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO cond
|
// TODO cond
|
||||||
|
|||||||
Reference in New Issue
Block a user