1. Are you planning to upload your awesome tool to Hive? Please review the rules here.
    July 9, 2018: The rules for the Tool Section have been revised. Please be sure to read the revisions.
    Dismiss Notice
  2. The poll for our 11th Music Contest is up! Help us choose the most awesome cinematic tracks by casting a vote!
    Dismiss Notice
  3. Melee Mapping contest #3 - Poll is up! Vote for the best 4v4 melee maps!
    Dismiss Notice
  4. The 30th edition of the Modeling Contest is finally up! The Portable Buildings need your attention, so come along and have a blast!
    Dismiss Notice
  5. The Aftermath has been revealed for the 19th Terraining Contest! Be sure to check out the Results and see what came out of it.
    Dismiss Notice

Jass Script Helper

Submitted by karaulov
This bundle is marked as approved. It works and satisfies the submission rules.
Tool for search unused locals, globals, functions.
And for optimize script and detect leaks.
Can save optimized script to file.

New version of Jass Script Warn Helper v2

12.05.2017: First release

13.05.2017: 1.2a version
+ Leak scanner
+ Bug fixes
+ Save script with remove unused globals, locals, functions, and fix leaks.

15.05.2017: 1.3a version
+ Configuration file! (can be edited default and hidden options)
+ Readme file :)

15.05.2017: 1.3b version
= Bug fixes (fix some cases bad detecting leaks)
15.05.2017: 1.4a version
+ fix missing INIFileParser.dll file
+ added first optimization in code
+ added warning messages
17.05.2017: 1.4e version
+ bug fixes
+ disable warning message for optimization

Features:
• Search unused globals
• Search unused locals
• Search unused functions
• Search leaks in code
• Optimize code
• Save result war3map.j file
• Uses multithread but too very slow if big input file :)


Example with default settings:


Example input:
Code (Text):
native MergeUnits           takes integer qty, integer a, integer b, integer make returns boolean




globals

    integer test1 = 0
    integer test2 = 0
    unit test3 = 0
    item test4 = 0
 
    code l__Code
    integer l__Int
 
endglobals


function UnusedFunction takes nothing returns nothing
    call Print("Hello world")
endfunction


function TestLeakArg takes unit u returns nothing
    set u = CreateUnit(...)
    call SetUnitSomething(u,...)
endfunction


function TestNoLeakArg takes unit u returns nothing
    set u = CreateUnit(...)
    call SetUnitSomething(u,...)
    set u = null
endfunction

function TestLeakVar takes nothing returns nothing
    local unit u = CreateUnit(...)
    call SetUnitSomething(u,...)
endfunction


function TestNoLeakVar takes unit u returns nothing
    local unit u = CreateUnit(...)
    call SetUnitSomething(u,...)
    if SomeFunc( ) == true then
        set u = null
        return
    endif
 
    if SomeFunc2( ) == true then
        return
    endif
 
    set u = null
    return
endfunction



function UseGlobals takes nothing returns nothing
    call TestFunction(test3)
    set test4 = ...
endfunction


function TestTypeCast takes nothing returns nothing
    local integer l__Code
    local code l__Int
endfunction

function TestUnusedLocal takes nothing returns nothing
    local unit u1 = null
    local unit u2 = u1
    local unit u3 = null
    local unit u4 = u1
    local unit u5 = null
    call TestFunction(...)
    call TestFunction(u2)
    set u2 = u3//
 
endfunction


function main takes nothing returns nothing
    call TestLeakArg( ... )
    call TestNoLeakArg( ... )
    call TestLeakVar( ... )
    call TestNoLeakVar( ... )
    call TestUnusedLocal( ... )
endfunction





function config takes nothing returns nothing
    call UseGlobals( ... )
endfunction
 
Example output:
Code (Text):
native MergeUnits           takes integer qty, integer a, integer b, integer make returns boolean
globals
    unit test3 = 0
    item test4 = 0
 
    code l__Code
    integer l__Int
endglobals


function TestLeakArg takes unit u returns nothing
    set u = CreateUnit(...)
    call SetUnitSomething(u,...)
    set u = null
endfunction


function TestNoLeakArg takes unit u returns nothing
    set u = CreateUnit(...)
    call SetUnitSomething(u,...)
    set u = null
endfunction

function TestLeakVar takes nothing returns nothing
    local unit u = CreateUnit(...)
    call SetUnitSomething(u,...)
    set u = null
endfunction


 
 
function TestNoLeakVar takes unit u returns nothing
    local unit u = CreateUnit(...)
    call SetUnitSomething(u,...)
    if SomeFunc( ) == true then
        set u = null
        return
    endif
    if SomeFunc2( ) == true then
        set u = null
        return
    endif
    set u = null
    return
endfunction



function UseGlobals takes nothing returns nothing
    call TestFunction(test3)
    set test4 = ...
endfunction
//Found typecast function. Local variable have same name as global variable!


function TestTypeCast takes nothing returns nothing
    local integer l__Code
    local code l__Int
endfunction

//
 
function TestUnusedLocal takes nothing returns nothing
    local unit u1 = null
    local unit u2 = u1
    local unit u3 = null
    call TestFunction(...)
    call TestFunction(u2)
    set u2 = u3
    set u2 = null
endfunction


function main takes nothing returns nothing
    call TestLeakArg( ... )
    call TestNoLeakArg( ... )
    call TestLeakVar( ... )
    call TestNoLeakVar( ... )
    call TestUnusedLocal( ... )
endfunction





function config takes nothing returns nothing
    call UseGlobals( ... )
endfunction
 
Contents

Jass Script Helper 1.4e (Binary)

Reviews
eejin
The tool does what it promises and the UI is simple and to the point. While it doesn't crash when using a map with VJass the output may not be entirely correct so this is something to keep in mind. As the tool warns do not replace your war3map.j with...
  1. karaulov

    karaulov

    Joined:
    Jun 17, 2010
    Messages:
    199
    Resources:
    3
    Tools:
    3
    Resources:
    3
    Update 1.2a

    New features!

    Now can auto fix leaks, and remove unused local variables.
    Added example of input/output data.
     
  2. Aniki

    Aniki

    Joined:
    Nov 7, 2014
    Messages:
    498
    Resources:
    4
    Spells:
    1
    JASS:
    3
    Resources:
    4
    input
    Code (vJASS):

    function TestLeakArg takes unit u returns nothing
        set u = CreateUnit(...)
        call SetUnitSomething(u,...)
    endfunction
     


    output
    Code (vJASS):

    function TestLeakArg takes unit u returns nothing
        set u = CreateUnit(...)
        call SetUnitSomething(u,...)
        set u = null
    endfunction
     


    I think arguments don't need to be set to null, they get pushed on the stack (push instruction) and cleaned up with the cleanstack instruction, so a handle's reference count doesn't change at all or it first gets incremented by the push and then decremented by the cleanstack, either way the ref count stays the same.

    Edit: it could be the 0x08 (poparg) instruction as well, I don't know =)

    Its nice that the tool can detect typecasting, rather than removing "unused" functions/globals =).
     
    Last edited: May 14, 2017
  3. karaulov

    karaulov

    Joined:
    Jun 17, 2010
    Messages:
    199
    Resources:
    3
    Tools:
    3
    Resources:
    3
    arg auto cleaned after function execute ? :( I don't know :)

    Update 1.3a:
    • Added configuration and readme files


    Possible in new version i can add auto code optimization ( but i don't know what need optimize :) )


    Example :

    Unoptimized??:
    Code (Text):
    globals
    endglobals

    function1 ..
       ...
       call Func...(GetTriggerUnit...)
       call Func...(GetTriggerUnit...)
       call Func...(GetTriggerUnit...)
       ...
    endfunction

    function2 ..
       ...
       call Func...(GetTriggerUnit...)
       call Func...(GetTriggerUnit...)
       call Func...(GetTriggerUnit...)
       ...
    endfunction

    function3 ..
       ...
       call Func...(GetTriggerUnit...)
       call Func...(GetTriggerUnit...)
       call Func...(GetTriggerUnit...)
       ...
    endfunction

    function TestOptimize ...
    call function1
    call function2
    call function3
    endfunction
     
    Optimized ???:
    Code (Text):
    globals
     unit GetTriggerUnit0 = null
    endglobals

    function1 ..
       ...
       call Func...(GetTriggerUnit0...)
       call Func...(GetTriggerUnit0...)
       call Func...(GetTriggerUnit0...)
       ...
    endfunction

    function2 ..
       ...
       call Func...(GetTriggerUnit0...)
       call Func...(GetTriggerUnit0...)
       call Func...(GetTriggerUnit0...)
       ...
    endfunction

    function3 ..
       ...
       call Func...(GetTriggerUnit0...)
       call Func...(GetTriggerUnit0...)
       call Func...(GetTriggerUnit0...)
       ...
    endfunction

    function TestOptimize ...
    set GetTriggerUnit0 = GetTriggerUnit( )
    call function1
    call function2
    call function3
    endfunction
     
    This is optimization or no ? :D


    15.05.2017: 1.3b version
    = Bug fixes (fix some cases bad detecting leaks)



    15.05.2017: 1.4a version
    + fix missing INIFileParser.dll file
    + added first optimization in code
    + added warning messages



    After enable Leak fix and Optimize code, you need manually move changes from war3map_opt.j to your script. (Leak fix can be unitialize vars in very few cases)
     
    Last edited: May 20, 2017
  4. Furry Nova

    Furry Nova

    Joined:
    Jun 22, 2016
    Messages:
    71
    Resources:
    0
    Resources:
    0
    It would be great if it could scan the map's war3map.j file and print all the issues in the Command Prompt. Having all the logs recorded in separate log files can be time consuming.
     
  5. KevicMitnic

    KevicMitnic

    Joined:
    Apr 3, 2018
    Messages:
    1
    Resources:
    0
    Resources:
    0
    How can this software use video to teach it? ?
     
  6. karaulov

    karaulov

    Joined:
    Jun 17, 2010
    Messages:
    199
    Resources:
    3
    Tools:
    3
    Resources:
    3
  7. eejin

    eejin

    Tool Reviewer

    Joined:
    Mar 6, 2017
    Messages:
    116
    Resources:
    0
    Resources:
    0
    The tool does what it promises and the UI is simple and to the point. While it doesn't crash when using a map with VJass the output may not be entirely correct so this is something to keep in mind.

    As the tool warns do not replace your war3map.j with the optimized output, but rather copy/move the optimizations by hand.

    Adding VJass support and automatically extracting the war3map.j file from a map would be nice additions.

    Approved!