From 3a5c4f2164ed490780e909c2982381e104e9afff Mon Sep 17 00:00:00 2001 From: Redar13 <93761434+Redar13@users.noreply.github.com> Date: Wed, 6 Nov 2024 20:39:09 +0500 Subject: [PATCH 1/2] Fix ending in with #end in the file (#5) * Update Parser.hx * Update Parser.hx --- hscript/Parser.hx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hscript/Parser.hx b/hscript/Parser.hx index 9d96213..189e6ce 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -2003,9 +2003,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; From bb46d45d567c7b7d1c80eed6eed43cc02e2d37cb Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Fri, 15 Nov 2024 15:25:04 +0100 Subject: [PATCH 2/2] Import Redirects --- hscript/Interp.hx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hscript/Interp.hx b/hscript/Interp.hx index 6833b4c..67f9ba8 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -473,6 +473,21 @@ class Interp { return v; } + 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; @@ -503,6 +518,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); @@ -519,6 +536,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;