diff --git a/hscript/Interp.hx b/hscript/Interp.hx index 27e1199..23e61a5 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -575,6 +575,21 @@ class Interp { return null; } + public static var importRedirects:Map = new Map(); + public static function getImportRedirect(className:String):String { + return importRedirects.exists(className) ? importRedirects.get(className) : className; + } + + public var localImportRedirects:Map = new Map(); + public function getLocalImportRedirect(className:String):String { + var className = className; + if (importRedirects.exists(className)) + className = importRedirects.get(className); + if (localImportRedirects.exists(className)) + className = localImportRedirects.get(className); + return className; + } + public function expr(e:Expr):Dynamic { #if hscriptPos curExpr = e; @@ -605,6 +620,8 @@ class Interp { if (variables.exists(toSetName)) // class is already imported return null; + var realClassName = getLocalImportRedirect(realClassName); + if (importBlocklist.contains(realClassName)) return null; var cl = Type.resolveClass(realClassName); @@ -621,6 +638,8 @@ class Interp { splitClassName.splice(-2, 1); // Remove the last last item realClassName = splitClassName.join("."); + var realClassName = getLocalImportRedirect(realClassName); + if (importBlocklist.contains(realClassName)) return null; diff --git a/hscript/Parser.hx b/hscript/Parser.hx index e9ff400..f3cedf1 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -2080,9 +2080,14 @@ class Parser { var pos = readPos; while( true ) { var tk = token(); - // TODO: Fix ending in with #end in the file - if( tk == TEof ) - error(EInvalidPreprocessor("Unclosed"), pos, pos); + + if( tk == TEof ) { + if (preprocStack.length != 0) { + error(EInvalidPreprocessor("Unclosed"), pos, pos); + } else { + break; + } + } if( preprocStack[spos] != obj ) { push(tk); break;