diff --git a/hscript/CustomClass.hx b/hscript/CustomClass.hx index b46404b..6a8ab99 100644 --- a/hscript/CustomClass.hx +++ b/hscript/CustomClass.hx @@ -48,6 +48,12 @@ class CustomClass implements IHScriptCustomClassBehaviour { __interp.staticVariables = __class.ogInterp.staticVariables; __interp.customClasses = __class.ogInterp.customClasses; + for(f => v in __class.__interp.variables) { + if(f == 'new') continue; + if (!__interp.variables.exists(f)) + __interp.variables.set(f, v); + } + for (f in __class.fields) { switch (Tools.expr(f)) { case EVar(n): __class__fields.push(n); @@ -59,11 +65,6 @@ class CustomClass implements IHScriptCustomClassBehaviour { @:privateAccess __interp.exprReturn(f); } - for (f => v in __class.__interp.variables) { - if (!__interp.variables.exists(f)) - __interp.variables.set(f, v); - } - __interp.scriptObject = this; initializing = true; diff --git a/hscript/CustomClassHandler.hx b/hscript/CustomClassHandler.hx index 9cb1f94..b200545 100644 --- a/hscript/CustomClassHandler.hx +++ b/hscript/CustomClassHandler.hx @@ -56,6 +56,10 @@ class CustomClassHandler implements IHScriptCustomConstructor implements IHScrip __interp.staticVariables = ogInterp.staticVariables; __interp.customClasses = ogInterp.customClasses; + for(f => v in ogInterp.variables) + if(!__interp.variables.exists(f)) + __interp.variables.set(f, v); + for(e in fields.copy()) { var validField:Bool = false; var staticField:Bool = false; @@ -78,10 +82,6 @@ class CustomClassHandler implements IHScriptCustomConstructor implements IHScrip fields.remove(e); } } - - for(f => v in ogInterp.variables) - if(!__interp.variables.exists(f)) - __interp.variables.set(f, v); } public function hnew(args:Array):Dynamic