From 5d2a99d40ec0c740bfc4c7d05a39ae8fcb23ccfd Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Tue, 3 Sep 2024 15:28:33 +0200 Subject: [PATCH] More Optimizations --- hscript/Interp.hx | 1 + hscript/Parser.hx | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/hscript/Interp.hx b/hscript/Interp.hx index 149177e..1a05417 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -64,6 +64,7 @@ class RedeclaredVar { public var depth:Int; } +@:analyzer(optimize, local_dce, fusion, user_var_fusion) class Interp { public var scriptObject(default, set):Dynamic; private var _hasScriptObject(default, null):Bool = false; diff --git a/hscript/Parser.hx b/hscript/Parser.hx index fa5fcf7..fd21aa5 100644 --- a/hscript/Parser.hx +++ b/hscript/Parser.hx @@ -51,6 +51,7 @@ final class TokenInfo { public var t : Token; } +@:analyzer(optimize, local_dce, fusion, user_var_fusion) class Parser { // config / variables @@ -2040,7 +2041,7 @@ class Parser { return preprocesorValues.get(id); } - var preprocStack : Array; + var preprocStack : Array; function parsePreproCond():Expr { var tk = token(); @@ -2103,20 +2104,20 @@ class Parser { case "if": var e = parsePreproCond(); if( evalPreproCond(e) ) { - preprocStack.push(true); + preprocStack.push({r: true}); return token(); } - preprocStack.push(false); + preprocStack.push({r: false}); skipTokens(); return token(); case "else", "elseif" if( preprocStack.length > 0 ): - if( preprocStack[preprocStack.length - 1] ) { - preprocStack[preprocStack.length - 1] = false; + if( preprocStack[preprocStack.length - 1].r ) { + preprocStack[preprocStack.length - 1].r = false; skipTokens(); return token(); } else if( id == "else" ) { preprocStack.pop(); - preprocStack.push(true); + preprocStack.push({r: true}); return token(); } else { // elseif @@ -2222,5 +2223,9 @@ class Parser { case TPrepro(id): "#" + id; } } +} +@:structInit +final class PreprocValue { + public var r : Bool; } \ No newline at end of file