Skip to content

Commit

Permalink
Add env.add(pack.to.Module) macro sugar
Browse files Browse the repository at this point in the history
Resolves to env.addModule('pack.to.Module', interpret.DynamicModule.fromStatic(pack.to.Module))
  • Loading branch information
kLabz committed Dec 7, 2021
1 parent 94c2cb3 commit f5d18f5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions interpret/Env.hx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ class Env {

} //addDefaultModules

/** Helper to simplify usual addModule() calls */
public macro function add(ethis, typePath:haxe.macro.Expr):haxe.macro.Expr {
return macro $ethis.addModule(
$v{haxe.macro.ExprTools.toString(typePath)},
interpret.DynamicModule.fromStatic($typePath)
);
}

/** Add dynamic module */
public function addModule(typePath:String, module:DynamicModule):Void {

Expand Down

0 comments on commit f5d18f5

Please sign in to comment.