Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48ec0f4b01 | ||
|
|
49c90e6434 | ||
|
|
bb46d45d56 | ||
|
|
3a5c4f2164 |
+1
-1
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "hscript",
|
||||
"name": "hscript-improved",
|
||||
"url": "https://github.com/HaxeFoundation/hscript",
|
||||
"license": "MIT",
|
||||
"description": "Haxe Script is a scripting engine for a subset of the Haxe language",
|
||||
|
||||
@@ -473,6 +473,21 @@ class Interp {
|
||||
return v;
|
||||
}
|
||||
|
||||
public static var importRedirects:Map<String, String> = new Map();
|
||||
public static function getImportRedirect(className:String):String {
|
||||
return importRedirects.exists(className) ? importRedirects.get(className) : className;
|
||||
}
|
||||
|
||||
public var localImportRedirects:Map<String, String> = 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;
|
||||
|
||||
|
||||
+13
-5
@@ -60,10 +60,10 @@ class Parser {
|
||||
/**
|
||||
allows to check for #if / #else in code
|
||||
**/
|
||||
public var preprocesorValues : Map<String,Dynamic> = new Map();
|
||||
public var preprocessorValues : Map<String,Dynamic> = new Map();
|
||||
|
||||
/**
|
||||
activate JSON compatiblity
|
||||
activate JSON compatibility
|
||||
**/
|
||||
public var allowJSON : Bool;
|
||||
|
||||
@@ -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;
|
||||
@@ -2089,4 +2094,7 @@ class Parser {
|
||||
}
|
||||
}
|
||||
|
||||
@:noCompletion public var preprocesorValues(get,set) : Map<String,Dynamic>;
|
||||
inline function get_preprocesorValues() return this.preprocessorValues;
|
||||
inline function set_preprocesorValues(v) return this.preprocessorValues = v;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user