This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main { | |
static function main() { | |
var x = 7; | |
var y = 10; | |
tools.Assert.assert(x == 7 && y == 11); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
class MyMacro { | |
public static function build( url : String ) { | |
var h = haxe.Http.requestUrl(url); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@:genericBuild(MyMacro.infer()) | |
class DeclType<Const> { } | |
class Main { | |
static function main() { | |
var values = [for (i in 0...10) { i : i, hello: true }]; | |
var list = []; | |
function example(v:DeclType<[values[0]]>) { | |
trace(v.i); | |
list.push(v); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract ArrayRead<T>(Array<T>) from Array<T> { | |
@:arrayAccess inline function get(i:Int):T return this[i]; | |
public var length(get,never):Int; | |
inline function get_length() return this.length; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import haxe.macro.Context; | |
import haxe.macro.Expr; | |
import haxe.macro.Printer; | |
import haxe.macro.Type; | |
using haxe.macro.Tools; | |
// The original code used interfaces to define properties, and some interfaces | |
// had the same property name with different types. These interfaces are then | |
// implemented by classes that provide the implementation of those properties. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main { | |
static var fields = MyMacro.buildFieldsArray(); | |
static function main() { | |
trace(fields); // [x,y,test,fields,main] | |
} | |
var x:Int; | |
var y:String; | |
function test() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@:genericBuild(MyMacro.buildTuple()) | |
class Tuple<Const> { } | |
class Main { | |
static public function main() { | |
var t = new Tuple<3>(1, "foo", true); | |
trace(t.v0); | |
trace(t.v1); | |
trace(t.v2); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main { | |
static function main() { | |
trace("Hello world"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Main { | |
public static function main () { | |
var cfgString = "{ | |
'someValue': ::(values.width-305)/2 + values.height::, | |
'constantValue': 13 | |
}"; | |
var template = new templo.Template(new haxe.io.StringInput(cfgString)); | |
var values = { | |
width: 500, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum E<T> { | |
BoolLit(b:Bool):E<Bool>; | |
IntLit(i:Int):E<Int>; | |
} | |
class Main { | |
static function main() { } | |
static function sameType<S>(o1:E<S>, o2:E<S>):Bool { | |
return switch [o1, o2] { // Unmatched patterns: [_,IntLit] |
NewerOlder