From b7c421cad2103dd5cd6c17d7315fd71096e45a1b Mon Sep 17 00:00:00 2001 From: back2dos Date: Thu, 27 Jun 2013 13:43:04 +0200 Subject: [PATCH] Moved bouncer back top package. --- haxelib.json | 2 +- src/tink/macro/{helpers => }/Bouncer.hx | 13 ++++++------- src/tink/macro/Positions.hx | 1 - src/tink/macro/Tools.hx | 3 ++- tests/Run.hx | 23 +++++++++++++++++++++++ 5 files changed, 32 insertions(+), 10 deletions(-) rename src/tink/macro/{helpers => }/Bouncer.hx (74%) create mode 100644 tests/Run.hx diff --git a/haxelib.json b/haxelib.json index 4fa2278..ce9d2bc 100644 --- a/haxelib.json +++ b/haxelib.json @@ -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" diff --git a/src/tink/macro/helpers/Bouncer.hx b/src/tink/macro/Bouncer.hx similarity index 74% rename from src/tink/macro/helpers/Bouncer.hx rename to src/tink/macro/Bouncer.hx index a44c3ed..0b87986 100644 --- a/src/tink/macro/helpers/Bouncer.hx +++ b/src/tink/macro/Bouncer.hx @@ -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 MapExpr>(); @@ -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):Bouncer return null; - + #end macro public function andBounce(ethis:Expr, id:Int) { return switch (ethis.expr) { diff --git a/src/tink/macro/Positions.hx b/src/tink/macro/Positions.hx index 7bf1e8d..eb8f0a6 100644 --- a/src/tink/macro/Positions.hx +++ b/src/tink/macro/Positions.hx @@ -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; diff --git a/src/tink/macro/Tools.hx b/src/tink/macro/Tools.hx index 4f458ef..d268edc 100644 --- a/src/tink/macro/Tools.hx +++ b/src/tink/macro/Tools.hx @@ -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; diff --git a/tests/Run.hx b/tests/Run.hx new file mode 100644 index 0000000..66e1de7 --- /dev/null +++ b/tests/Run.hx @@ -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 = [ + + ]; + static function main() { + test();//it compiles!!! + } + #end + macro static function test() { + return macro null; + } +} \ No newline at end of file