Skip to content

Commit

Permalink
dorkument
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn committed Feb 28, 2022
1 parent 6b1f8b8 commit 1f7de73
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions std/haxe/macro/Context.hx
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,15 @@ class Context {
return load("timer", 1)(id);
}

/**
Executes `code` in a context that has `imports` and `usings` added.
This is equivalent to temporarily having `import` and `using` statements in a file. These
are only active during the execution of `code` and do not affect anything afterwards. This
is true even if `code` throws an exception.
If any argument is `null`, the result is unspecified.
**/
public static function withImports<X>(imports:Array<String>, usings:Array<String>, code:() -> X):X {
return load("with_imports", 3)(imports, usings, code);
}
Expand Down

0 comments on commit 1f7de73

Please sign in to comment.