Moved bouncer back top package.
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"tags": ["tink", "macro", "utility"],
|
||||
"description": "The macro toolkit ;)",
|
||||
"version": "0.0.0-alpha.2",
|
||||
"releasenote": "Shorter names.",
|
||||
"releasenote": "Overall refactoring.",
|
||||
"contributors": ["back2dos"],
|
||||
"dependencies": {
|
||||
"tink_core": "1.1.0-alpha.2"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package tink.macro.helpers;
|
||||
package tink.macro;
|
||||
|
||||
#if macro
|
||||
import haxe.macro.Context;
|
||||
@@ -7,8 +7,7 @@ package tink.macro.helpers;
|
||||
using tink.macro.Positions;
|
||||
using tink.macro.Exprs;
|
||||
#end
|
||||
class Bouncer {
|
||||
//TODO: as is, a more less empty class is generated in the output. This is unneccessary.
|
||||
@:exclude class Bouncer {
|
||||
#if macro
|
||||
static var idCounter = 0;
|
||||
static var bounceMap = new Map<Int,Void->Expr>();
|
||||
@@ -16,13 +15,13 @@ class Bouncer {
|
||||
static public function bounce(f:Void->Expr, ?pos) {
|
||||
var id = idCounter++;
|
||||
bounceMap.set(id, f);
|
||||
return 'tink.macro.helpers.Bouncer.catchBounce'.resolve(pos).call([id.toExpr(pos)], pos);
|
||||
return 'tink.macro.Bouncer.catchBounce'.resolve(pos).call([id.toExpr(pos)], pos);
|
||||
}
|
||||
static public function outerTransform(e:Expr, transform:Expr->Expr) {
|
||||
var id = idCounter++,
|
||||
pos = e.pos;
|
||||
outerMap.set(id, transform);
|
||||
return 'tink.macro.helpers.Bouncer.makeOuter'.resolve(pos).call([e], pos).field('andBounce', pos).call([id.toExpr(pos)], pos);
|
||||
return 'tink.macro.Bouncer.makeOuter'.resolve(pos).call([e], pos).field('andBounce', pos).call([id.toExpr(pos)], pos);
|
||||
}
|
||||
static function doOuter(id:Int, e:Expr) {
|
||||
return
|
||||
@@ -38,10 +37,10 @@ class Bouncer {
|
||||
else
|
||||
Context.currentPos().error('unknown id ' + id);
|
||||
}
|
||||
#end
|
||||
#else
|
||||
static public function makeOuter<A>(a:A):Bouncer
|
||||
return null;
|
||||
|
||||
#end
|
||||
macro public function andBounce(ethis:Expr, id:Int) {
|
||||
return
|
||||
switch (ethis.expr) {
|
||||
@@ -2,7 +2,6 @@ package tink.macro;
|
||||
|
||||
import haxe.macro.Context;
|
||||
import haxe.macro.Expr;
|
||||
import tink.macro.helpers.Bouncer;
|
||||
|
||||
using tink.macro.Positions;
|
||||
using tink.core.Outcome;
|
||||
|
||||
@@ -6,10 +6,11 @@ package tink.macro;
|
||||
typedef _Exprs = Exprs;
|
||||
typedef _Functions = Functions;
|
||||
typedef _Metadatas = Metadatas;
|
||||
typedef _Bouncer = tink.macro.helpers.Bouncer;
|
||||
typedef _Bouncer = Bouncer;
|
||||
typedef _Types = Types;
|
||||
typedef _Binops = Ops.Binary;
|
||||
typedef _Unops = Ops.Unary;
|
||||
typedef _Outcomes = tink.core.Outcome.OutcomeTools;
|
||||
#end
|
||||
class Tools {
|
||||
static var idCounter = 0;
|
||||
|
||||
23
tests/Run.hx
Normal file
23
tests/Run.hx
Normal file
@@ -0,0 +1,23 @@
|
||||
package ;
|
||||
|
||||
#if !macro
|
||||
import haxe.unit.TestCase;
|
||||
import haxe.unit.TestRunner;
|
||||
import neko.Lib;
|
||||
#else
|
||||
import haxe.macro.*;
|
||||
using tink.macro.Tools;
|
||||
#end
|
||||
class Run {
|
||||
#if !macro
|
||||
static var tests:Array<TestCase> = [
|
||||
|
||||
];
|
||||
static function main() {
|
||||
test();//it compiles!!!
|
||||
}
|
||||
#end
|
||||
macro static function test() {
|
||||
return macro null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user