File: Main2.hx

package info (click to toggle)
haxe 1%3A4.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 40,556 kB
  • sloc: ml: 125,171; ansic: 2,408; makefile: 436; java: 362; cs: 323; cpp: 318; python: 316; sh: 75; objc: 64; php: 39; xml: 30; javascript: 11
file content (107 lines) | stat: -rw-r--r-- 2,226 bytes parent folder | download | duplicates (4)
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()
		};
	}
}