• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

New Script Optimizer

Status
Not open for further replies.
Actually, it would be looping through every 6 characters and if the string is equal to "==true", then you would do nothing but add 6 to the index in the loop and skip it :p
But, if the first character is ", then you'd have to loop until you hit another " (making sure the character before it has isn't a backslash. :3
When you hit the second ", you'd continue deleting.
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
I don't get this sentence :
So if a map script contains X white spaces, they will be kept, no matter they are not necessary ?
Or, white spaces in strings are also removed ?
No. As I said, Froptimizer will/is part of WurstScript Compiler (a project me and peq are working on).
And the JassPrinter module has 2 modes, 1 with whitespaces and one without.
Basically I'm just not looping through the whole script.

Actually, it would be looping through every 6 characters and if the string is equal to "==true", then you would do nothing but add 6 to the index in the loop and skip it :p
But, if the first character is ", then you'd have to loop until you hit another " (making sure the character before it has isn't a backslash. :3
When you hit the second ", you'd continue deleting.
dont overcomplicate it.

Btw @the EF and TRVE name compressing.
At the moment they are handled this way:
-If the argument inside EF/TRVE is only a constant string, it will be compressed.

-If it is a mix of a constant string and an expression, e.g. I2S all functions that have the same pattern ( const + expr | expr + const | expr + const + expr ) will be ignored from name compression.

You could ofc compress the constant part of the pattern, but what the heck, just use short names if you wanna have expressions in EF/TRVE
 
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
Glad to know that you've choiced the hardest but most powerfull way to handle ExecuteFunc.
I suppose you will do the same with (globals) real variables and TriggerRegisterVariableEvent ?

Btw what is WurstCompiler, "just" a jass script optimizer (don't take me wrong i'm not trying to reduce its usefulness), or more ?
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
Glad to know that you've choiced the hardest but most powerfull way to handle ExecuteFunc.
I suppose you will do the same with (globals) real variables and TriggerRegisterVariableEvent ?

Btw what is WurstCompiler, "just" a jass script optimizer (don't take me wrong i'm not trying to reduce its usefulness), or more ?

Yea. Choiced. :thumbs_up:
I did write EF/TRVE since they are kinda the same
What about global reals?

WurstScript will be a new scripting language (will be presented here soon~)
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I don't know what TRVE stands for, but i just mean reals used by TriggerRegisterVariableEvent.
Btw, the "__protected" keyword i've suggested should still be also implemented, because sometimes the string argument could be a variable without any constant string.

OFF-TOPIC :

Erf, indent based language.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Did some tests :

JASS:
/*
wc3 version : 1.26.0.6401
text displayed :

variable event x
variable event X
variable event x
variable event X
f1
F1

*/

library Test initializer init

    globals
        real x = 0
        real X = 0
    endglobals

    function f1 takes nothing returns nothing
        call BJDebugMsg("f1")
    endfunction
    
    function F1 takes nothing returns nothing
        call BJDebugMsg("F1")
    endfunction
    
    function F takes nothing returns nothing
        call BJDebugMsg("variable event local")
    endfunction
    
    private function VE_x takes nothing returns nothing
        call BJDebugMsg("variable event x")
    endfunction
    
    private function VE_X takes nothing returns nothing
        call BJDebugMsg("variable event X")
    endfunction
    
    private function init takes nothing returns nothing
        local trigger trig
        local real r = 0
        
        call TriggerSleepAction(0) // for message available in the box
        
        call TriggerRegisterVariableEvent(trig,"r",EQUAL,1)
        call TriggerAddAction(trig,function F)
        set r = 1
        
        set trig = CreateTrigger()
        call TriggerRegisterVariableEvent(trig,"x",EQUAL,1)
        call TriggerAddAction(trig,function VE_x)
        
        set trig = CreateTrigger()
        call TriggerRegisterVariableEvent(trig,"X",EQUAL,1)
        call TriggerAddAction(trig,function VE_X)
        
        set x = 1
        set X = 1
        
        call ExecuteFunc("f1")
        call ExecuteFunc("F1")
    endfunction

endlibrary

Conclusion :

Yep, local reals don't work with TriggerRegisterVariableEvent, so no problem.
Yes, TRVE don't care about the case, which shouldn't be a problem for a decent coder, but must be definetely taken in consideration for a script optimizer.
No, ExecuteFunc hopefully care about the case.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Hmm ExecuteFunc is case sensitive now? I wonder though if it would still execute the wrong-case function if the right-case function was not found.

Are you sure you don't confuse with gamecache ?
I've never used ExecuteFunc but that doesn't really make sense, his behavior probably has never changed during patches.

I will test your doubt right after my lunch.

Done :

JASS:
/*
wc3 version : 1.26.0.6401

displayed text :

no crash, yeah !

*/

library Test initializer init

    function f1 takes nothing returns nothing
        call BJDebugMsg("f1")
    endfunction
    
    function F2 takes nothing returns nothing
        call BJDebugMsg("F1")
    endfunction
    
    private function init takes nothing returns nothing
        local trigger trig = CreateTrigger()
        local real r = 0
        
        call TriggerSleepAction(0) // for message available in the box
        
        call ExecuteFunc("")
        call ExecuteFunc(null)
        call ExecuteFunc("/n")
        call ExecuteFunc("this is a sentence")
        call ExecuteFunc("whatever")
        
        call ExecuteFunc("F1")
        call ExecuteFunc("f2")
        
        call BJDebugMsg("no crash, yeah !")
    endfunction

endlibrary

Now, that i'm posting it, i remember that ExecuteFunc made a wc3 crash when an invalid string argument was used (at least that's what i've read).
So it could make sense that his previous behavior was not case sensitive.

An unknown old bug fix is still better than an unknown new bug :p
 
Last edited:
Level 17
Joined
Apr 27, 2008
Messages
2,455
To be honest if i would be mod, i would reject such resources.
Hell, even historic languages where the short names had a reason tend to forbid this behavior.

Like the "new" C convention : C99 (i know it's not the newest but all features are still not yet fully implemented even for popular compilers, such as gcc).

I mean there is a simple reason behind that :

human != computer

Sorry for off-topic but i had to say it :p
 

Bribe

Code Moderator
Level 50
Joined
Sep 26, 2009
Messages
9,464
"Sh*t code" being approved is just because I have to do something with it. I first told other people to take the position because I have only been coding for X amount of time but none of the more qualified people were interested in the job. I made some mistakes and took some early action at some points, but the choice was either for me to do it or for no one to do it. If someone else comes along like Troll-Brain whose got the time I don't mind him taking over.
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
"Sh*t code" being approved is just because I have to do something with it. I first told other people to take the position because I have only been coding for X amount of time but none of the more qualified people were interested in the job. I made some mistakes and took some early action at some points, but the choice was either for me to do it or for no one to do it. If someone else comes along like Troll-Brain whose got the time I don't mind him taking over.

Cool story bro.
now get back on topic.

project will be released when i got the updater working.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Some other ideas :

- Player(X), should be remplaced by P[X] where P is a global player array initialized with the 16 players.
- Same for GetLocalPlayer(), except of course it doesn't need to be an array (you can't use GetLocalPlayer in a global definition, because wc3 crashes, but the "main" function is enough for that)
- Remove unused variables (yes it is very possible to have many of them, especially using vJass, think about scope/library created in an empty trigger, there is still the gg_trg... trigger globals lying in the script)

Also i repeat myself, but plz allow it to be used in command line, it's not hard to implement anyway and will be useful.
 
Last edited:
Level 23
Joined
Jan 1, 2009
Messages
1,608
Btw, you reserve one letter for locals variables ?
no
Some other ideas :

- Player(X), should be remplaced by P[X] where P is a global player array initialized with the 16 players.
- Same for GetLocalPlayer(), except of course it doesn't need to be an array (you can't use GetLocalPlayer in a global definition, because wc3 crashes, but the "main" function is enough for that)
The user can do that without a problem
- Remove unused variables (yes it is very possible to have many of them, especially using vJass, think about scope/library created in an empty trigger, there is still the gg_trg... trigger globals lying in the script)
Unused functions and variables will be removed by the inlining module.
But vJass won't be supported anyway.
Also i repeat myself, but plz allow it to be used in command line, it's not hard to implement anyway and will be useful.
there is a cmd line for wurst, but don't think its needed.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455

Hmm it's bad since if you do that, you will be able to use many more times one letter words.

The user can do that without a problem

Not really it's annoying to have a library with an initializer just for that.
I prefer use Player()

Unused functions and variables will be removed by the inlining module.
But vJass won't be supported anyway.

While i understand it's a pain in the ass to support multiple grammars, i'm lost, are we not talking about a script optimizer here ?!
I mean we are not talking about a jass preprocessor here.
If you want to talk about wurst, you should create a new thread.

there is a cmd line for wurst, but don't think its needed.

Actually i was suggesting it for the script optimizer.

Btw i'm afraid now, are you basically saying that we won't be able to use the script optimizer without your jass preprocessor, all will be merged ?
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
Ok, if you are doing a whole new script, here are some things you should probably let everyone know about...


support for importing external script files
Lua support (is it still a pain in the ass to do it in WE, or is it just plain not supported?)
all the other pre processing stuff vjass supports
nested macros?
macros calling macros?
smart modules?
smart inliner?
will the syntax still be open for w/e (like structs that extend arrays), or are you forcing private code like a lot of the scripting languages for SC2 do.


I'm personally of the idea that Lua would be a wonderful preprocessing language since it's already used by grimoire.

etc
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
While i understand it's a pain in the ass to support multiple grammars, i'm lost, are we not talking about a script optimizer here ?!
I mean we are not talking about a jass preprocessor here.
If you want to talk about wurst, you should create a new thread.
Btw i'm afraid now, are you basically saying that we won't be able to use the script optimizer without your jass preprocessor, all will be merged ?
Yes, I mentioned that 2 times allready...
The optimizer will be inbuilt into the compiler, since it uses the same parsing.
I could probably make it as a halfass standalone application, but things like inlining and removing unused stuff is much easier to handle by the compiler.
Ok, if you are doing a whole new script, here are some things you should probably let everyone know about...

support for importing external script files y
Lua support (is it still a pain in the ass to do it in WE, or is it just plain not supported?)
all the other pre processing stuff vjass supports
nested macros?
macros calling macros? there won't be any macros
smart modules? whatever you understand by that
smart inliner? y, also forced inlining at some point
will the syntax still be open for w/e (like structs that extend arrays), or are you forcing private code like a lot of the scripting languages for SC2 do.
Wurst will be very different from vJass and I don't know what sc2 does tbh.

etc
The Thread will be opened soon enough, so dont post it here.
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
I wanted people to use it as standalone, now it's not standalone anymore, but a feature of wurst.
The optimizer does does most optimizations on the intermediate language (between wurst and jass). Ripping it out of the enviroment wouldn't be easy to do and some features would be missing (have to write a jass parser just for that).
As said 10 times before, yes.
Maybe there will be a standalone, but it's not a high priority
 
Level 23
Joined
Jan 1, 2009
Messages
1,608
Sooo, I wrote a jassParser (which will get public when I finish validating) and rethought the idea of a standalone Optimizer and revived Froptimizer.
The basic features are implemented and should work, as all of my testing did.
Download & extract the File from the first post and run FroptimizerUI.jar

Even though vexorian fixed the native-bug in his optimizer, he doesn't fix it in EF and TRVE (?) so imo this project still has the right to exist and will be updated with more features regarding mapscript-optimization and maybe a few general optimizations.

Please test & report any bugs. Thx
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
It's not always about better, but also different.
I could design a small executable which would be executed by grimoire after mapsave so that you could test your map with an optimized code without having to externally/manually do it.

Go for it.
You will even have more testers, as JNGP is the most common way to write (v)Jass code.
It will also make benchmarks code more realiable, or at least less annoying to do.
 
Last edited:
Level 23
Joined
Jan 1, 2009
Messages
1,608
Go for it.
You will even have more testers, as JNGP is the most common way to write (v)Jass code.
It will also make benchmarks code more realiable, or at least less annoying to do.

I will when I finished my JassParser so it can replace pjass, as I need it to build the AST for the optimizer anyway.
 
Status
Not open for further replies.
Top