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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/**
* This is not really a valid Haxe file, but just an demo...
*/
package;
package net.onthewings;
import net.onthewings.Test;
import net.onthewings.*;
using Lambda;
using net.onthewings.Test;
#if flash8
// Haxe code specific for flash player 8
#elseif flash
// Haxe code specific for flash platform (any version)
#elseif js
// Haxe code specific for javascript plaform
#elseif neko
// Haxe code specific for neko plaform
#else
// do something else
#error // will display an error "Not implemented on this platform"
#error "Custom error message" // will display an error "Custom error message"
#end
0; // Int
-134; // Int
0xFF00; // Int
123.0; // Float
.14179; // Float
13e50; // Float
-1e-99; // Float
"hello"; // String
"hello \"world\" !"; // String
'hello "world" !'; // String
true; // Bool
false; // Bool
null; // Unknown<0>
~/[a-z]+/i; // EReg : regular expression
var point = { "x" : 1, "y" : -5 };
{
var x;
var y = 3;
var z : String;
var w : String = "";
var a, b : Bool, c : Int = 0;
}
class Test <T:Void->Void> {
private function new():Void {
inline function innerFun(a:Int, b:Int):Int {
return readOnlyField = a + b;
}
_innerFun(1, 2.3);
}
static public var instance(get,null):Test;
static function get_instance():Test {
return instance != null ? instance : instance = new Test();
}
}
@:native("Test") private class Test2 {}
extern class Ext {}
@:macro class M {
@:macro static function test(e:Array<Expr>):ExprOf<String> {
return macro "ok";
}
}
enum Color {
Red;
Green;
Blue;
Grey( v : Int );
Rgb( r : Int, g : Int, b : Int );
Alpha( a : Int, col : Color );
}
class Colors {
static function toInt( c : Color ) : Int {
return switch( c ) {
case Red: 0xFF0000;
case Green: 0x00FF00;
case Blue: 0x0000FF;
case Grey(v): (v << 16) | (v << 8) | v;
case Rgb(r,g,b): (r << 16) | (g << 8) | b;
case Alpha(a,c): (a << 24) | (toInt(c) & 0xFFFFFF);
}
}
}
class EvtQueue<T : (Event, EventDispatcher)> {
var evt : T;
}
typedef DS = Dynamic<String>;
typedef Pt = {
var x:Float;
var y:Float;
@:optional var z:Float; /* optional z */
function add(pt:Pt):Void;
}
typedef Pt2 = {
x:Float,
y:Float,
?z:Float, //optional z
add : Point -> Void,
}
|