From dc084611516e8f3eeedf05089a382531c4dd1383 Mon Sep 17 00:00:00 2001 From: David Elahee Date: Thu, 28 Sep 2017 09:54:56 +0200 Subject: [PATCH 1/4] tiny opt --- hscript/Interp.hx | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/hscript/Interp.hx b/hscript/Interp.hx index 32bb7dd0..daee14ec 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -29,11 +29,29 @@ private enum Stop { SReturn( v : Dynamic ); } +@:structInit +private class Declared { + public var n : String; + public var old : Hashed; + public function new(n,old){ + this.n = n; + this.old = old; + } +} + +@:structInit +private class Hashed { + public var r : Dynamic; + public function new(r){ + this.r = r; + } +} + class Interp { #if haxe3 public var variables : Map; - var locals : Map; + var locals : Map; var binops : Map Expr -> Dynamic >; #else public var variables : Hash; @@ -43,7 +61,7 @@ class Interp { var depth : Int; var inTry : Bool; - var declared : Array<{ n : String, old : { r : Dynamic } }>; + var declared : Array; #if hscriptPos var curExpr : Expr; @@ -446,7 +464,7 @@ class Interp { } else { // function-in-function is a local function declared.push( { n : name, old : locals.get(name) } ); - var ref = { r : f }; + var ref : Hashed = { r : f }; locals.set(name, ref); capturedLocals.set(name, ref); // allow self-recursion } From 3e6dcdcf8291051223b143b44820214c07d7c447 Mon Sep 17 00:00:00 2001 From: David Elahee Date: Sun, 1 Oct 2017 11:33:34 +0200 Subject: [PATCH 2/4] workaround for java? --- hscript/Interp.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hscript/Interp.hx b/hscript/Interp.hx index daee14ec..7c7d1f46 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -402,7 +402,7 @@ class Interp { case EReturn(e): throw SReturn((e == null)?null:expr(e)); case EFunction(params,fexpr,name,_): - var capturedLocals = duplicate(locals); + var capturedLocals : Map = duplicate(locals); var me = this; var hasOpt = false, minParams = 0; for( p in params ) From 1154cc0a485d451c22800a26ff41bd247dcfdc55 Mon Sep 17 00:00:00 2001 From: delahee Date: Thu, 7 Mar 2019 10:00:17 +0100 Subject: [PATCH 3/4] remove some flash install stuff --- flash/.gitignore | 3 -- flash/Install.hx | 94 ---------------------------------------------- flash/Run.hx | 54 -------------------------- flash/install.hxml | 2 - flash/run.hxml | 2 - 5 files changed, 155 deletions(-) delete mode 100644 flash/.gitignore delete mode 100644 flash/Install.hx delete mode 100644 flash/Run.hx delete mode 100644 flash/install.hxml delete mode 100644 flash/run.hxml diff --git a/flash/.gitignore b/flash/.gitignore deleted file mode 100644 index 640713cc..00000000 --- a/flash/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.exe -*.app -flashplayerdebugger \ No newline at end of file diff --git a/flash/Install.hx b/flash/Install.hx deleted file mode 100644 index 64cef386..00000000 --- a/flash/Install.hx +++ /dev/null @@ -1,94 +0,0 @@ -import Sys.*; -import sys.io.File.*; -import haxe.*; -import haxe.io.*; - -class Install { - // https://www.adobe.com/support/flashplayer/downloads.html - static var fpDownload(default, never) = switch (systemName()) { - case "Linux": - "http://fpdownload.macromedia.com/pub/flashplayer/updaters/25/flash_player_sa_linux_debug.x86_64.tar.gz"; - case "Mac": - "http://fpdownload.macromedia.com/pub/flashplayer/updaters/25/flashplayer_25_sa_debug.dmg"; - case "Windows": - "http://fpdownload.macromedia.com/pub/flashplayer/updaters/25/flashplayer_25_sa_debug.exe"; - case _: - throw "unsupported system"; - } - // https://helpx.adobe.com/flash-player/kb/configure-debugger-version-flash-player.html - static var mmcfg(default, never) = switch (systemName()) { - case "Linux": - Path.join([getEnv("HOME"), "mm.cfg"]); - case "Mac": - "/Library/Application Support/Macromedia/mm.cfg"; - case "Windows": - Path.join([getEnv("HOMEDRIVE") + getEnv("HOMEPATH"), "mm.cfg"]); - case _: - throw "unsupported system"; - } - // http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7c95.html - static var fpTrust(default, never) = switch (systemName()) { - case "Linux": - Path.join([getEnv("HOME"), ".macromedia/Flash_Player/#Security/FlashPlayerTrust"]); - case "Mac": - "/Library/Application Support/Macromedia/FlashPlayerTrust"; - case "Windows": - Path.join([getEnv("SYSTEMROOT"), "system32", "Macromed", "Flash", "FlashPlayerTrust"]); - case _: - throw "unsupported system"; - } - static function main() { - switch (systemName()) { - case "Linux": - // Download and unzip flash player - if (command("wget", [fpDownload]) != 0) - throw "failed to download flash player"; - if (command("tar", ["-xf", Path.withoutDirectory(fpDownload), "-C", "flash"]) != 0) - throw "failed to extract flash player"; - case "Mac": - // https://github.com/caskroom/homebrew-cask/pull/15381 - if (command("brew", ["uninstall", "--force", "brew-cask"]) != 0) - throw "failed to brew uninstall --force brew-cask"; - if (command("brew", ["tap", "caskroom/versions"]) != 0) - throw "failed to brew tap caskroom/versions"; - if (command("brew", ["cask", "install", "flash-player-debugger"]) != 0) - throw "failed to install flash-player-debugger"; - case "Windows": - // Download flash player - download(fpDownload, "flash\\flashplayer.exe"); - case _: - throw "unsupported system"; - } - - - // Create a configuration file so the trace log is enabled - createDirectory(Path.directory(mmcfg)); - saveContent(mmcfg, "ErrorReportingEnable=1\nTraceOutputFileEnable=1"); - - // Add the current directory as trusted, so exit() can be used - createDirectory(fpTrust); - saveContent(Path.join([fpTrust, "test.cfg"]), getCwd()); - } - static function download(url:String, saveAs:String):Void { - var http = new Http(url); - http.onError = function(e) { - throw e; - }; - http.customRequest(false, write(saveAs)); - } - static function createDirectory(dir:String):Void { - try { - sys.FileSystem.createDirectory(dir); - } catch(e:Dynamic) { - switch (systemName()) { - case "Mac", "Linux": - if (command("sudo", ["mkdir", "-p", dir]) != 0) - throw 'cannot create $dir'; - if (command("sudo", ["chmod", "a+rw", dir]) != 0) - throw 'cannot set permission of $dir'; - case _: - throw 'cannot create $dir: $e'; - } - } - } -} \ No newline at end of file diff --git a/flash/Run.hx b/flash/Run.hx deleted file mode 100644 index beb27ab0..00000000 --- a/flash/Run.hx +++ /dev/null @@ -1,54 +0,0 @@ -import Sys.*; -import sys.FileSystem.*; -import sys.io.File.*; -import haxe.io.*; - -class Run { - // https://helpx.adobe.com/flash-player/kb/configure-debugger-version-flash-player.html - static var flashlog(default, never) = switch (systemName()) { - case "Linux": - Path.join([getEnv("HOME"), ".macromedia/Flash_Player/Logs/flashlog.txt"]); - case "Mac": - Path.join([getEnv("HOME"), "Library/Preferences/Macromedia/Flash Player/Logs/flashlog.txt"]); - case "Windows": - Path.join([getEnv("APPDATA"), "Macromedia", "Flash Player", "Logs", "flashlog.txt"]); - case _: - throw "unsupported system"; - } - static function main() { - var args = args(); - var swf = args[0]; - var exitCode = switch (systemName()) { - case "Linux": - // The flash player has some issues with unexplained crashes, - // but if it runs about 16 times, it should succeed one of those... - var c = -1; - for (i in 0...16) { - if ((c = command("xvfb-run", ["-a", "flash/flashplayerdebugger", swf])) == 0) - break; - println('retry... (${i+1})'); - sleep(1.5); - } - c; - case "Mac": - command("/Applications/Flash Player Debugger.app/Contents/MacOS/Flash Player Debugger", [fullPath(swf)]); - case "Windows": - command("flash\\flashplayer.exe", [fullPath(swf)]); - case _: - throw "unsupported platform"; - } - if (exists(flashlog)) - println(getContent(flashlog)); - else { - println('does not exist: $flashlog'); - var parts = Path.normalize(flashlog).split("/"); - println(parts); - for (i in 0...parts.length-1) { - var path = parts.splice(0, i+1).join("/"); - println('ls $path'); - command("ls", [path]); - } - } - exit(exitCode); - } -} \ No newline at end of file diff --git a/flash/install.hxml b/flash/install.hxml deleted file mode 100644 index 13219983..00000000 --- a/flash/install.hxml +++ /dev/null @@ -1,2 +0,0 @@ --cp flash ---run Install \ No newline at end of file diff --git a/flash/run.hxml b/flash/run.hxml deleted file mode 100644 index cf398327..00000000 --- a/flash/run.hxml +++ /dev/null @@ -1,2 +0,0 @@ --cp flash ---run Run \ No newline at end of file From 4df4188a287049956ab9a2b1defd659d432f8d77 Mon Sep 17 00:00:00 2001 From: delahee Date: Thu, 7 Mar 2019 11:01:14 +0100 Subject: [PATCH 4/4] doc for cpp usages --- hscript/Interp.hx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hscript/Interp.hx b/hscript/Interp.hx index 7c7d1f46..7d6471c2 100644 --- a/hscript/Interp.hx +++ b/hscript/Interp.hx @@ -98,9 +98,13 @@ class Interp { #else binops = new Hash(); #end + + /** + * BEWARE ON CPP TARGET INLINE VARIABLES ARE CULLED AND HAVE NO COUNTERPARTS + */ binops.set("+",function(e1,e2) return me.expr(e1) + me.expr(e2)); binops.set("-",function(e1,e2) return me.expr(e1) - me.expr(e2)); - binops.set("*",function(e1,e2) return me.expr(e1) * me.expr(e2)); + binops.set("*", function(e1, e2) { return me.expr(e1) * me.expr(e2);}); binops.set("/",function(e1,e2) return me.expr(e1) / me.expr(e2)); binops.set("%",function(e1,e2) return me.expr(e1) % me.expr(e2)); binops.set("&",function(e1,e2) return me.expr(e1) & me.expr(e2)); @@ -129,7 +133,8 @@ class Interp { assignOp("^=",function(v1,v2) return v1 ^ v2); assignOp("<<=",function(v1,v2) return v1 << v2); assignOp(">>=",function(v1,v2) return v1 >> v2); - assignOp(">>>=",function(v1,v2) return v1 >>> v2); + assignOp(">>>=", function(v1, v2) return v1 >>> v2); + } function assign( e1 : Expr, e2 : Expr ) : Dynamic {