Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
thautwarm committed Jun 30, 2020
1 parent 983be83 commit df9ad40
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions purescripto/purescript_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import ast
import io


class LoadPureScriptImplCode(LoaderForBetterLife[CodeType]):
def source_to_prog(self, src: bytes, path: Path) -> CodeType:
filename = str(path.absolute())
Expand All @@ -37,10 +36,22 @@ def dump_program(self, prog: CodeType) -> bytes:
def suffix(self) -> Union[str, Tuple[str, ...]]:
return ".zip.py", ".raw.py"


# to avoid the re-import of a module
# during importing it for the first time.
EXPORTS = {}
def LoadPureScript(file: str, name: str):
cache_key = (file, name)
cache_exports = EXPORTS.get(cache_key)
if cache_exports:
return cache_exports

loader = LoadPureScriptImplCode(file, name)
code = loader.load()
man_made_globals = RTS_TEMPLATE.copy()
exec(code, man_made_globals)
return man_made_globals["exports"]
cache_exports = man_made_globals["exports"]
if cache_key in EXPORTS:
raise Exception("Cross import file {} at {}.".format(file, name))

EXPORTS[cache_key] = cache_exports
return cache_exports
2 changes: 1 addition & 1 deletion purescripto/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = "0.8.8"
__version__ = "0.8.9"
__blueprint_version__ = '0.1.3'

0 comments on commit df9ad40

Please sign in to comment.