1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
import haxe.macro.Context;
import haxe.macro.Expr;
class Main2 {
static function main() {
invalidVariable("0_variable");
invalidVariable("var");
invalidVariable("new");
invalidVariable("foo \"\t\n");
invalidCatchVariable();
invalidFunctionName();
invalidFunctionArgumentName();
invalidPatternVariable();
invalidForVariable();
invalidForVariableKeyValue();
}
static macro function invalidVariable(name:String) {
return {
expr: EVars([{name: name, type: null, expr: null}]),
pos: Context.currentPos()
};
}
static macro function invalidCatchVariable() {
return {
expr: ETry(macro {}, [{name: "0_catchVariable", type: macro:Dynamic, expr: macro {}}]),
pos: Context.currentPos()
};
}
static macro function invalidFunctionName() {
return {
expr: EFunction(FNamed("0_function"), {
args: [],
ret: macro:Void,
expr: macro {}
}),
pos: Context.currentPos()
};
}
static macro function invalidFunctionArgumentName() {
return {
expr: EFunction(FNamed("foo"), {
args: [
{
name: "0_argument",
type: macro:Int
}
],
ret: macro:Void,
expr: macro {}
}),
pos: Context.currentPos()
};
}
static macro function invalidPatternVariable() {
return {
expr: ESwitch(macro "", [
{
values: [
{
expr: EConst(CIdent("0_patternVariable")),
pos: Context.currentPos()
}
],
expr: macro {}
}
], null),
pos: Context.currentPos()
};
}
static macro function invalidForVariable() {
return {
expr: EFor({
expr: EBinop(OpIn, {
expr: EConst(CIdent("0_forVariable")),
pos: Context.currentPos()
}, macro []),
pos: Context.currentPos()
}, macro {}),
pos: Context.currentPos()
};
}
static macro function invalidForVariableKeyValue() {
return {
expr: EFor({
expr: EBinop(OpIn, {
expr: EBinop(OpArrow, {
expr: EConst(CIdent("0_forVariableKey")),
pos: Context.currentPos()
}, {
expr: EConst(CIdent("0_forVariableValue")),
pos: Context.currentPos()
}),
pos: Context.currentPos()
}, macro new Map()),
pos: Context.currentPos()
}, macro {}),
pos: Context.currentPos()
};
}
}
|