|
@@ -25,102 +25,169 @@ package haxe.macro;
|
|
extern enum Position {
|
|
extern enum Position {
|
|
}
|
|
}
|
|
#else
|
|
#else
|
|
|
|
+/**
|
|
|
|
+ Represents a position in a file.
|
|
|
|
+**/
|
|
typedef Position = {
|
|
typedef Position = {
|
|
|
|
+ /**
|
|
|
|
+ Reference to the filename.
|
|
|
|
+ **/
|
|
var file : String;
|
|
var file : String;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Position of the first character.
|
|
|
|
+ **/
|
|
var min : Int;
|
|
var min : Int;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Position of the last character.
|
|
|
|
+ **/
|
|
var max : Int;
|
|
var max : Int;
|
|
}
|
|
}
|
|
#end
|
|
#end
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a constant.
|
|
|
|
+ @see http://haxe.org/manual/expression-constants.html
|
|
|
|
+**/
|
|
enum Constant {
|
|
enum Constant {
|
|
|
|
+ /**
|
|
|
|
+ Represents an integer literal.
|
|
|
|
+ **/
|
|
CInt( v : String );
|
|
CInt( v : String );
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ Represents a float literal.
|
|
|
|
+ **/
|
|
CFloat( f : String );
|
|
CFloat( f : String );
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ Represents a string literal.
|
|
|
|
+ **/
|
|
CString( s : String );
|
|
CString( s : String );
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ Represents an indentifier.
|
|
|
|
+ **/
|
|
CIdent( s : String );
|
|
CIdent( s : String );
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ Represents a regular expression literal.
|
|
|
|
+
|
|
|
|
+ Example: `~/haxe/i`
|
|
|
|
+ * The first argument _haxe_ is a string with regular expression pattern.
|
|
|
|
+ * The second argument _i_ is a string with regular expression flags.
|
|
|
|
+
|
|
|
|
+ @see http://haxe.org/manual/std-regex.html
|
|
|
|
+ **/
|
|
CRegexp( r : String, opt : String );
|
|
CRegexp( r : String, opt : String );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ A binary operator.
|
|
|
|
+ @see http://haxe.org/manual/types-numeric-operators.html
|
|
|
|
+**/
|
|
enum Binop {
|
|
enum Binop {
|
|
/**
|
|
/**
|
|
`+`
|
|
`+`
|
|
**/
|
|
**/
|
|
OpAdd;
|
|
OpAdd;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`*`
|
|
`*`
|
|
**/
|
|
**/
|
|
OpMult;
|
|
OpMult;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`/`
|
|
`/`
|
|
**/
|
|
**/
|
|
OpDiv;
|
|
OpDiv;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`-`
|
|
`-`
|
|
**/
|
|
**/
|
|
OpSub;
|
|
OpSub;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`=`
|
|
`=`
|
|
**/
|
|
**/
|
|
OpAssign;
|
|
OpAssign;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`==`
|
|
`==`
|
|
**/
|
|
**/
|
|
OpEq;
|
|
OpEq;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`!=`
|
|
`!=`
|
|
**/
|
|
**/
|
|
OpNotEq;
|
|
OpNotEq;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`>`
|
|
`>`
|
|
**/
|
|
**/
|
|
OpGt;
|
|
OpGt;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`>=`
|
|
`>=`
|
|
**/
|
|
**/
|
|
OpGte;
|
|
OpGte;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`<`
|
|
`<`
|
|
**/
|
|
**/
|
|
OpLt;
|
|
OpLt;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`<=`
|
|
`<=`
|
|
**/
|
|
**/
|
|
OpLte;
|
|
OpLte;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`&`
|
|
`&`
|
|
**/
|
|
**/
|
|
OpAnd;
|
|
OpAnd;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`|`
|
|
`|`
|
|
**/
|
|
**/
|
|
OpOr;
|
|
OpOr;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`^`
|
|
`^`
|
|
**/
|
|
**/
|
|
OpXor;
|
|
OpXor;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`&&`
|
|
`&&`
|
|
**/
|
|
**/
|
|
OpBoolAnd;
|
|
OpBoolAnd;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`||`
|
|
`||`
|
|
**/
|
|
**/
|
|
OpBoolOr;
|
|
OpBoolOr;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`<<`
|
|
`<<`
|
|
**/
|
|
**/
|
|
OpShl;
|
|
OpShl;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`>>`
|
|
`>>`
|
|
**/
|
|
**/
|
|
OpShr;
|
|
OpShr;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`>>>`
|
|
`>>>`
|
|
**/
|
|
**/
|
|
OpUShr;
|
|
OpUShr;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`%`
|
|
`%`
|
|
**/
|
|
**/
|
|
OpMod;
|
|
OpMod;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`+=`
|
|
`+=`
|
|
`-=`
|
|
`-=`
|
|
@@ -135,188 +202,660 @@ enum Binop {
|
|
`%=`
|
|
`%=`
|
|
**/
|
|
**/
|
|
OpAssignOp( op : Binop );
|
|
OpAssignOp( op : Binop );
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`...`
|
|
`...`
|
|
**/
|
|
**/
|
|
OpInterval;
|
|
OpInterval;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`=>`
|
|
`=>`
|
|
**/
|
|
**/
|
|
OpArrow;
|
|
OpArrow;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
|
|
+/**
|
|
|
|
+ A unary operator.
|
|
|
|
+ @see http://haxe.org/manual/types-numeric-operators.html
|
|
|
|
+**/
|
|
enum Unop {
|
|
enum Unop {
|
|
/**
|
|
/**
|
|
`++`
|
|
`++`
|
|
**/
|
|
**/
|
|
OpIncrement;
|
|
OpIncrement;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`--`
|
|
`--`
|
|
**/
|
|
**/
|
|
OpDecrement;
|
|
OpDecrement;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`!`
|
|
`!`
|
|
**/
|
|
**/
|
|
OpNot;
|
|
OpNot;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`-`
|
|
`-`
|
|
**/
|
|
**/
|
|
OpNeg;
|
|
OpNeg;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
`~`
|
|
`~`
|
|
**/
|
|
**/
|
|
OpNegBits;
|
|
OpNegBits;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a node in the AST.
|
|
|
|
+ @see http://haxe.org/manual/macro-reification-expression.html
|
|
|
|
+**/
|
|
typedef Expr = {
|
|
typedef Expr = {
|
|
|
|
+ /**
|
|
|
|
+ The expression kind.
|
|
|
|
+ **/
|
|
var expr : ExprDef;
|
|
var expr : ExprDef;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The position of the expression.
|
|
|
|
+ **/
|
|
var pos : Position;
|
|
var pos : Position;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a AST node identical to `Expr`, but it allows constraining the
|
|
|
|
+ type of accepted expressions.
|
|
|
|
+ @see http://haxe.org/manual/macro-ExprOf.html
|
|
|
|
+**/
|
|
typedef ExprOf<T> = Expr;
|
|
typedef ExprOf<T> = Expr;
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a switch case.
|
|
|
|
+ @see http://haxe.org/manual/expression-switch.html
|
|
|
|
+**/
|
|
typedef Case = {
|
|
typedef Case = {
|
|
|
|
+ /**
|
|
|
|
+ The value expressions of the case.
|
|
|
|
+ **/
|
|
var values : Array<Expr>;
|
|
var values : Array<Expr>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The optional guard expressions of the case, if available.
|
|
|
|
+ **/
|
|
@:optional var guard : Null<Expr>;
|
|
@:optional var guard : Null<Expr>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The expression of the case, if available.
|
|
|
|
+ **/
|
|
var expr: Null<Expr>;
|
|
var expr: Null<Expr>;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a variable in the AST.
|
|
|
|
+ @see http://haxe.org/manual/expression-var.html
|
|
|
|
+**/
|
|
typedef Var = {
|
|
typedef Var = {
|
|
|
|
+ /**
|
|
|
|
+ The name of the variable.
|
|
|
|
+ **/
|
|
name : String,
|
|
name : String,
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The type-hint of the variable, if available.
|
|
|
|
+ **/
|
|
type : Null<ComplexType>,
|
|
type : Null<ComplexType>,
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The expression of the variable, if available.
|
|
|
|
+ **/
|
|
expr : Null<Expr>
|
|
expr : Null<Expr>
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a catch in the AST.
|
|
|
|
+ @http://haxe.org/manual/expression-try-catch.html
|
|
|
|
+**/
|
|
typedef Catch = {
|
|
typedef Catch = {
|
|
|
|
+ /**
|
|
|
|
+ The name of the catch variable.
|
|
|
|
+ **/
|
|
name : String,
|
|
name : String,
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The type of the catch.
|
|
|
|
+ **/
|
|
type : ComplexType,
|
|
type : ComplexType,
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The expression of the catch.
|
|
|
|
+ **/
|
|
expr : Expr
|
|
expr : Expr
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents the kind of a node in the AST.
|
|
|
|
+**/
|
|
enum ExprDef {
|
|
enum ExprDef {
|
|
|
|
+ /**
|
|
|
|
+ A constant.
|
|
|
|
+ **/
|
|
EConst( c : Constant );
|
|
EConst( c : Constant );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Array access `e1[e2]`.
|
|
|
|
+ **/
|
|
EArray( e1 : Expr, e2 : Expr );
|
|
EArray( e1 : Expr, e2 : Expr );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Binary operator `e1 op e2`.
|
|
|
|
+ **/
|
|
EBinop( op : Binop, e1 : Expr, e2 : Expr );
|
|
EBinop( op : Binop, e1 : Expr, e2 : Expr );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Field access on `e.field`.
|
|
|
|
+ **/
|
|
EField( e : Expr, field : String );
|
|
EField( e : Expr, field : String );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Parentheses `(e)`.
|
|
|
|
+ **/
|
|
EParenthesis( e : Expr );
|
|
EParenthesis( e : Expr );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ An object declaration.
|
|
|
|
+ **/
|
|
EObjectDecl( fields : Array<{ field : String, expr : Expr }> );
|
|
EObjectDecl( fields : Array<{ field : String, expr : Expr }> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ An array declaration `[el]`.
|
|
|
|
+ **/
|
|
EArrayDecl( values : Array<Expr> );
|
|
EArrayDecl( values : Array<Expr> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A call `e(params)`.
|
|
|
|
+ **/
|
|
ECall( e : Expr, params : Array<Expr> );
|
|
ECall( e : Expr, params : Array<Expr> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A constructor call `new t(params)`.
|
|
|
|
+ **/
|
|
ENew( t : TypePath, params : Array<Expr> );
|
|
ENew( t : TypePath, params : Array<Expr> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ An unary operator `op` on `e`:
|
|
|
|
+
|
|
|
|
+ * e++ (op = OpIncrement, postFix = true)
|
|
|
|
+ * e-- (op = OpDecrement, postFix = true)
|
|
|
|
+ * ++e (op = OpIncrement, postFix = false)
|
|
|
|
+ * --e (op = OpDecrement, postFix = false)
|
|
|
|
+ * -e (op = OpNeg, postFix = false)
|
|
|
|
+ * !e (op = OpNot, postFix = false)
|
|
|
|
+ * ~e (op = OpNegBits, postFix = false)
|
|
|
|
+ **/
|
|
EUnop( op : Unop, postFix : Bool, e : Expr );
|
|
EUnop( op : Unop, postFix : Bool, e : Expr );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Variable declarations.
|
|
|
|
+ **/
|
|
EVars( vars : Array<Var> );
|
|
EVars( vars : Array<Var> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A function declaration.
|
|
|
|
+ **/
|
|
EFunction( name : Null<String>, f : Function );
|
|
EFunction( name : Null<String>, f : Function );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A block of expressions `{exprs}`.
|
|
|
|
+ **/
|
|
EBlock( exprs : Array<Expr> );
|
|
EBlock( exprs : Array<Expr> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A `for` expression.
|
|
|
|
+ **/
|
|
EFor( it : Expr, expr : Expr );
|
|
EFor( it : Expr, expr : Expr );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A `(e1 in e2)` expression.
|
|
|
|
+ **/
|
|
EIn( e1 : Expr, e2 : Expr );
|
|
EIn( e1 : Expr, e2 : Expr );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ An `if(econd) eif` or `if(econd) eif else eelse` expression.
|
|
|
|
+ **/
|
|
EIf( econd : Expr, eif : Expr, eelse : Null<Expr> );
|
|
EIf( econd : Expr, eif : Expr, eelse : Null<Expr> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents a `while` expression.
|
|
|
|
+ When `normalWhile` is `true` it is `while (...)`.
|
|
|
|
+ When `normalWhile` is `false` it is `do {...} while (...)`.
|
|
|
|
+ **/
|
|
EWhile( econd : Expr, e : Expr, normalWhile : Bool );
|
|
EWhile( econd : Expr, e : Expr, normalWhile : Bool );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents a `switch` expression with related cases and an optional.
|
|
|
|
+ `default` case if edef != null.
|
|
|
|
+ **/
|
|
ESwitch( e : Expr, cases : Array<Case>, edef : Null<Null<Expr>> );
|
|
ESwitch( e : Expr, cases : Array<Case>, edef : Null<Null<Expr>> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents a `try`-expression with related catches.
|
|
|
|
+ **/
|
|
ETry( e : Expr, catches : Array<Catch> );
|
|
ETry( e : Expr, catches : Array<Catch> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A `return` or `return e` expression.
|
|
|
|
+ **/
|
|
EReturn( ?e : Null<Expr> );
|
|
EReturn( ?e : Null<Expr> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A `break` expression.
|
|
|
|
+ **/
|
|
EBreak;
|
|
EBreak;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A `continue` expression.
|
|
|
|
+ **/
|
|
EContinue;
|
|
EContinue;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ An `untyped e` source code.
|
|
|
|
+ **/
|
|
EUntyped( e : Expr );
|
|
EUntyped( e : Expr );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A `throw e` expression.
|
|
|
|
+ **/
|
|
EThrow( e : Expr );
|
|
EThrow( e : Expr );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A `cast e` or `cast (e, m)` expression.
|
|
|
|
+ **/
|
|
ECast( e : Expr, t : Null<ComplexType> );
|
|
ECast( e : Expr, t : Null<ComplexType> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Internally used to provide completion.
|
|
|
|
+ **/
|
|
EDisplay( e : Expr, isCall : Bool );
|
|
EDisplay( e : Expr, isCall : Bool );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Internally used to provide completion.
|
|
|
|
+ **/
|
|
EDisplayNew( t : TypePath );
|
|
EDisplayNew( t : TypePath );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A `(econd) ? eif : eelse` expression.
|
|
|
|
+ **/
|
|
ETernary( econd : Expr, eif : Expr, eelse : Expr );
|
|
ETernary( econd : Expr, eif : Expr, eelse : Expr );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A `(e:t)` expression.
|
|
|
|
+ **/
|
|
ECheckType( e : Expr, t : ComplexType );
|
|
ECheckType( e : Expr, t : ComplexType );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ A `@m e` expression.
|
|
|
|
+ **/
|
|
EMeta( s : MetadataEntry, e : Expr );
|
|
EMeta( s : MetadataEntry, e : Expr );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a type syntax in the AST.
|
|
|
|
+**/
|
|
enum ComplexType {
|
|
enum ComplexType {
|
|
|
|
+ /**
|
|
|
|
+ Represents the type path.
|
|
|
|
+ **/
|
|
TPath( p : TypePath );
|
|
TPath( p : TypePath );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents a function type.
|
|
|
|
+ @see http://haxe.org/manual/types-function.html
|
|
|
|
+ **/
|
|
TFunction( args : Array<ComplexType>, ret : ComplexType );
|
|
TFunction( args : Array<ComplexType>, ret : ComplexType );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents an anonymous structure type.
|
|
|
|
+ @see http://haxe.org/manual/types-anonymous-structure.html
|
|
|
|
+ **/
|
|
TAnonymous( fields : Array<Field> );
|
|
TAnonymous( fields : Array<Field> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents parentheses around a type, e.g. the `(Int -> Void)` part in
|
|
|
|
+ `(Int -> Void) -> String`.
|
|
|
|
+ **/
|
|
TParent( t : ComplexType );
|
|
TParent( t : ComplexType );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents typedef extensions `> Iterable<T>`.
|
|
|
|
+ The array `p` holds the type paths to the given types.
|
|
|
|
+ @see http://haxe.org/manual/type-system-extensions.html
|
|
|
|
+ **/
|
|
TExtend( p : Array<TypePath>, fields : Array<Field> );
|
|
TExtend( p : Array<TypePath>, fields : Array<Field> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents an optional type.
|
|
|
|
+ **/
|
|
TOptional( t : ComplexType );
|
|
TOptional( t : ComplexType );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a type path in the AST.
|
|
|
|
+**/
|
|
typedef TypePath = {
|
|
typedef TypePath = {
|
|
|
|
+ /**
|
|
|
|
+ Represents the package of the type path.
|
|
|
|
+ **/
|
|
var pack : Array<String>;
|
|
var pack : Array<String>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The name of the type path.
|
|
|
|
+ **/
|
|
var name : String;
|
|
var name : String;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Optional parameters of the type path.
|
|
|
|
+ **/
|
|
@:optional var params : Array<TypeParam>;
|
|
@:optional var params : Array<TypeParam>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Sub is set on module sub-type access:
|
|
|
|
+ `pack.Module.Type` has name = Module, sub = Type, if available.
|
|
|
|
+ **/
|
|
@:optional var sub : Null<String>;
|
|
@:optional var sub : Null<String>;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a concrete type parameters in the AST.
|
|
|
|
+
|
|
|
|
+ Haxe allows expressions in concrete type parameters, e.g.
|
|
|
|
+ `new YourType<["hello", "world"]>`. In that case the value is `TPExpr` while
|
|
|
|
+ in the normal case it's `TPType`.
|
|
|
|
+**/
|
|
enum TypeParam {
|
|
enum TypeParam {
|
|
|
|
+ /**
|
|
|
|
+
|
|
|
|
+ **/
|
|
TPType( t : ComplexType );
|
|
TPType( t : ComplexType );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+
|
|
|
|
+ **/
|
|
TPExpr( e : Expr );
|
|
TPExpr( e : Expr );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a type parameter declaration in the AST.
|
|
|
|
+**/
|
|
typedef TypeParamDecl = {
|
|
typedef TypeParamDecl = {
|
|
|
|
+ /**
|
|
|
|
+ The name of the type parameter.
|
|
|
|
+ **/
|
|
var name : String;
|
|
var name : String;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The optional constraints of the type parameter.
|
|
|
|
+ **/
|
|
@:optional var constraints : Array<ComplexType>;
|
|
@:optional var constraints : Array<ComplexType>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The optional parameters of the type parameter.
|
|
|
|
+ **/
|
|
@:optional var params : Array<TypeParamDecl>;
|
|
@:optional var params : Array<TypeParamDecl>;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a function in the AST.
|
|
|
|
+**/
|
|
typedef Function = {
|
|
typedef Function = {
|
|
|
|
+ /**
|
|
|
|
+ A list of function arguments.
|
|
|
|
+ **/
|
|
var args : Array<FunctionArg>;
|
|
var args : Array<FunctionArg>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The return type-hint of the function, if available.
|
|
|
|
+ **/
|
|
var ret : Null<ComplexType>;
|
|
var ret : Null<ComplexType>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The expression of the function body, if available.
|
|
|
|
+ **/
|
|
var expr : Null<Expr>;
|
|
var expr : Null<Expr>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ An optional list of function parameter type declarations.
|
|
|
|
+ **/
|
|
@:optional var params : Array<TypeParamDecl>;
|
|
@:optional var params : Array<TypeParamDecl>;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a function argument in the AST.
|
|
|
|
+**/
|
|
typedef FunctionArg = {
|
|
typedef FunctionArg = {
|
|
|
|
+ /**
|
|
|
|
+ The name of the function argument.
|
|
|
|
+ **/
|
|
var name : String;
|
|
var name : String;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Whether or not the function argument is optional.
|
|
|
|
+ **/
|
|
@:optional var opt : Bool;
|
|
@:optional var opt : Bool;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The type-hint of the function argument, if available.
|
|
|
|
+ **/
|
|
var type : Null<ComplexType>;
|
|
var type : Null<ComplexType>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The optional value of the function argument, if available.
|
|
|
|
+ **/
|
|
@:optional var value : Null<Expr>;
|
|
@:optional var value : Null<Expr>;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a metadata entry in the AST.
|
|
|
|
+**/
|
|
typedef MetadataEntry = {
|
|
typedef MetadataEntry = {
|
|
|
|
+ /**
|
|
|
|
+ The name of the metadata entry.
|
|
|
|
+ **/
|
|
name : String,
|
|
name : String,
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The optional parameters of the metadata entry.
|
|
|
|
+ **/
|
|
?params : Array<Expr>,
|
|
?params : Array<Expr>,
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The position of the metadata entry.
|
|
|
|
+ **/
|
|
pos : Position
|
|
pos : Position
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents metadata in the AST.
|
|
|
|
+**/
|
|
typedef Metadata = Array<MetadataEntry>;
|
|
typedef Metadata = Array<MetadataEntry>;
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a field in the AST.
|
|
|
|
+**/
|
|
typedef Field = {
|
|
typedef Field = {
|
|
|
|
+ /**
|
|
|
|
+ The name of the field.
|
|
|
|
+ **/
|
|
var name : String;
|
|
var name : String;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The documentation of the field, if available. If the field has no
|
|
|
|
+ documentation, the value is `null`.
|
|
|
|
+ **/
|
|
@:optional var doc : Null<String>;
|
|
@:optional var doc : Null<String>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The access modifiers of the field. By default fields have private access.
|
|
|
|
+ @see http://haxe.org/manual/class-field-access-modifier.html
|
|
|
|
+ **/
|
|
@:optional var access : Array<Access>;
|
|
@:optional var access : Array<Access>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The kind of the field.
|
|
|
|
+ **/
|
|
var kind : FieldType;
|
|
var kind : FieldType;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The position of the field.
|
|
|
|
+ **/
|
|
var pos : Position;
|
|
var pos : Position;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The optional metadata of the field.
|
|
|
|
+ **/
|
|
@:optional var meta : Metadata;
|
|
@:optional var meta : Metadata;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents an access modifier.
|
|
|
|
+ @see http://haxe.org/manual/class-field-access-modifier.html
|
|
|
|
+**/
|
|
enum Access {
|
|
enum Access {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Public access modifier, grants access from anywhere.
|
|
|
|
+ @see http://haxe.org/manual/class-field-visibility.html
|
|
|
|
+ **/
|
|
APublic;
|
|
APublic;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Private access modifier, grants access to class and its sub-classes
|
|
|
|
+ only.
|
|
|
|
+ @see http://haxe.org/manual/class-field-visibility.html
|
|
|
|
+ **/
|
|
APrivate;
|
|
APrivate;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Static access modifier.
|
|
|
|
+ **/
|
|
AStatic;
|
|
AStatic;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Override access modifier.
|
|
|
|
+ @see http://haxe.org/manual/class-field-override.html
|
|
|
|
+ **/
|
|
AOverride;
|
|
AOverride;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Dynamic (re-)bindable access modifier.
|
|
|
|
+ @see http://haxe.org/manual/class-field-dynamic.html
|
|
|
|
+ **/
|
|
ADynamic;
|
|
ADynamic;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Inline access modifier. Allows expressions to be directly inserted in
|
|
|
|
+ place of calls to them.
|
|
|
|
+ @see http://haxe.org/manual/class-field-inline.html
|
|
|
|
+ **/
|
|
AInline;
|
|
AInline;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Macros access modifier. Allows expression macro functions. These are
|
|
|
|
+ normal functions which are executed as soon as they are typed.
|
|
|
|
+ **/
|
|
AMacro;
|
|
AMacro;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents the field type in the AST.
|
|
|
|
+**/
|
|
enum FieldType {
|
|
enum FieldType {
|
|
|
|
+ /**
|
|
|
|
+ Represents a variable field type.
|
|
|
|
+ **/
|
|
FVar( t : Null<ComplexType>, ?e : Null<Expr> );
|
|
FVar( t : Null<ComplexType>, ?e : Null<Expr> );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents a function field type.
|
|
|
|
+ **/
|
|
FFun( f : Function );
|
|
FFun( f : Function );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents a property with getter and setter field type.
|
|
|
|
+ **/
|
|
FProp( get : String, set : String, ?t : Null<ComplexType>, ?e : Null<Expr> );
|
|
FProp( get : String, set : String, ?t : Null<ComplexType>, ?e : Null<Expr> );
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a type definition.
|
|
|
|
+**/
|
|
typedef TypeDefinition = {
|
|
typedef TypeDefinition = {
|
|
|
|
+ /**
|
|
|
|
+ The package of the type definition.
|
|
|
|
+ **/
|
|
var pack : Array<String>;
|
|
var pack : Array<String>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The name of the type definition.
|
|
|
|
+ **/
|
|
var name : String;
|
|
var name : String;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The position to the type definition.
|
|
|
|
+ **/
|
|
var pos : Position;
|
|
var pos : Position;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The optional metadata of the type definition.
|
|
|
|
+ **/
|
|
@:optional var meta : Metadata;
|
|
@:optional var meta : Metadata;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The paramater type declarations of the type definition.
|
|
|
|
+ **/
|
|
@:optional var params : Array<TypeParamDecl>;
|
|
@:optional var params : Array<TypeParamDecl>;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Whether or not the type is extern.
|
|
|
|
+ **/
|
|
@:optional var isExtern : Bool;
|
|
@:optional var isExtern : Bool;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The kind of the type definition.
|
|
|
|
+ **/
|
|
var kind : TypeDefKind;
|
|
var kind : TypeDefKind;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The fields of the type definition.
|
|
|
|
+ **/
|
|
var fields : Array<Field>;
|
|
var fields : Array<Field>;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents a type definition kind.
|
|
|
|
+**/
|
|
enum TypeDefKind {
|
|
enum TypeDefKind {
|
|
|
|
+ /**
|
|
|
|
+ Represents an enum kind.
|
|
|
|
+ **/
|
|
TDEnum;
|
|
TDEnum;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents a structure kind.
|
|
|
|
+ **/
|
|
TDStructure;
|
|
TDStructure;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents a class kind.
|
|
|
|
+ **/
|
|
TDClass( ?superClass : TypePath, ?interfaces : Array<TypePath>, ?isInterface : Bool );
|
|
TDClass( ?superClass : TypePath, ?interfaces : Array<TypePath>, ?isInterface : Bool );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents an alias/typedef kind.
|
|
|
|
+ **/
|
|
TDAlias( t : ComplexType ); // ignore TypeDefinition.fields
|
|
TDAlias( t : ComplexType ); // ignore TypeDefinition.fields
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents an abstract kind.
|
|
|
|
+ **/
|
|
TDAbstract( tthis : Null<ComplexType>, ?from : Array<ComplexType>, ?to: Array<ComplexType> );
|
|
TDAbstract( tthis : Null<ComplexType>, ?from : Array<ComplexType>, ?to: Array<ComplexType> );
|
|
}
|
|
}
|
|
|
|
|
|
@@ -324,24 +863,65 @@ enum TypeDefKind {
|
|
This error can be used to handle or produce compilation errors in macros.
|
|
This error can be used to handle or produce compilation errors in macros.
|
|
**/
|
|
**/
|
|
class Error {
|
|
class Error {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The error message.
|
|
|
|
+ **/
|
|
public var message : String;
|
|
public var message : String;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The position of the error.
|
|
|
|
+ **/
|
|
public var pos : Expr.Position;
|
|
public var pos : Expr.Position;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Instantiates an error with given message and position.
|
|
|
|
+ **/
|
|
public function new(m,p) {
|
|
public function new(m,p) {
|
|
this.message = m;
|
|
this.message = m;
|
|
this.pos = p;
|
|
this.pos = p;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Returns the string representation of the error.
|
|
|
|
+ **/
|
|
function toString() {
|
|
function toString() {
|
|
return message;
|
|
return message;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents the import mode.
|
|
|
|
+ @see http://haxe.org/manual/type-system-import.html
|
|
|
|
+**/
|
|
enum ImportMode {
|
|
enum ImportMode {
|
|
|
|
+ /**
|
|
|
|
+ Represents a default import `import c`.
|
|
|
|
+ **/
|
|
INormal;
|
|
INormal;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents the alias import `import c as alias`.
|
|
|
|
+ **/
|
|
IAsName(alias:String);
|
|
IAsName(alias:String);
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ Represents the wildcard import `import *`.
|
|
|
|
+ **/
|
|
IAll;
|
|
IAll;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/**
|
|
|
|
+ Represents the import expression.
|
|
|
|
+**/
|
|
typedef ImportExpr = {
|
|
typedef ImportExpr = {
|
|
|
|
+ /**
|
|
|
|
+ The path to the import expression.
|
|
|
|
+ **/
|
|
var path: Array< { pos: Position, name: String } >;
|
|
var path: Array< { pos: Position, name: String } >;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ The mode of the import expression.
|
|
|
|
+ **/
|
|
var mode: ImportMode;
|
|
var mode: ImportMode;
|
|
}
|
|
}
|