Rename haxe macro withPos()

This commit is contained in:
2020-11-24 16:48:00 -07:00
parent 3a8f38c5e1
commit 8019c8893d
3 changed files with 10 additions and 10 deletions

View File

@@ -6,7 +6,7 @@ import haxe.macro.Context;
using StringTools;
class Helpers {
public static function withPos(e:ExprDef):Expr {
public static function withContextPos(e:ExprDef):Expr {
return {
pos: Context.currentPos(),
expr: e

View File

@@ -64,9 +64,9 @@ class Macros {
EFunction(FArrow, {
args: [],
ret: null,
expr: EReturn(k.convert(callArg)).withPos()
}).withPos()
]).withPos();
expr: EReturn(k.convert(callArg)).withContextPos()
}).withContextPos()
]).withContextPos();
};
CallExp(Symbol("defun"), exps);

View File

@@ -37,7 +37,7 @@ class SpecialForms {
case Symbol(name): name;
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
@@ -77,7 +77,7 @@ class SpecialForms {
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
@@ -100,7 +100,7 @@ class SpecialForms {
ECheckType(convert(args[1]), switch (args[0]) {
case Symbol(type): Helpers.parseComplexType(type);
default: throw 'first argument to (the... ) should be a valid type';
}).withPos();
}).withContextPos();
};
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';
}
}
]).withPos();
]).withContextPos();
};
map["throw"] = (args:Array<ReaderExp>, convert:ExprConversion) -> {
if (args.length != 1) {
throw 'throw expression should only throw one value, not: $args';
}
EThrow(convert(args[0])).withPos();
EThrow(convert(args[0])).withContextPos();
};
map["<"] = foldComparison("_min");
@@ -154,7 +154,7 @@ class SpecialForms {
var thenExp = convert(args[1]);
var elseExp = if (args.length > 2) convert(args[2]) else null;
EIf(condition, thenExp, elseExp).withPos();
EIf(condition, thenExp, elseExp).withContextPos();
};
// TODO cond