View Single Post
Old 01-29-2015, 05:45 PM   #3633
Nestharus
User
 
Join Date: Jul 2007
Posts: 220

Nestharus has little to show at this moment (6)

Default

The following does not work

Collapse JASS:
module A
endmodule

module B
    dsfsfds
endmodule

module C
    static if false then
        static if false then
            implement A
        else
            implement B //this is implemented and commented out
        endif
    else
        implement B //this doesn't exist
    endif
endmodule

The following does not work.

Collapse JASS:
struct A
    static method test takes nothing returns nothing
    endmethod
endstruct

module K
    private static method test takes nothing returns nothing
        call A.test() //K__test is not a member of A
    endmethod
endmodule

struct B
    implement K
endstruct

The following generates syntax errors during variable generation

Collapse JASS:
scope M

globals
    debug private integer i

    //the above gives
    //    private integer

    //the following is also legal to do, but gives incorrect output
    debug private constant boolean m = true

    //the above gives
    //    private constant= true
endglobals

endscope

The following isn't caught by the parser

Collapse JASS:
struct O

//everything after "returns nothing" is ignored
private static method sfidsjof takes nothing returns nothing dsfdushfui sdfds sf afa  fsdfds
endmethod

endstruct

The following isn't caught by the parser

Collapse JASS:
function D takes nothing returns nothing
endfunction

function M takes nothing returns nothing
    //you shouldn't be able to compare a function to an integer
    if (D == 1) then
    endif
endfunction



It is currently possible to access private members with a percent chance of success.


This isn't correct. A private scope's contents should be private to the parent scope.

Collapse JASS:
scope c
    private scope d
        function m takes nothing returns nothing
        endfunction
    endscope
endscope
scope e
    function d takes nothing returns nothing
        call m()
    endfunction
endscope

Ambiguity between scopes and identifiers

Collapse JASS:
scope o
    public function o takes nothing returns nothing
    endfunction
endscope

function o_o takes nothing returns nothing
endfunction


The following is valid in one case and not valid in the other

Collapse JASS:
module b
    //the following is valid
    private method _c takes nothing returns nothing
    endmethod
    
    //the following is not valid
    method _d takes nothing returns nothing
    endmethod
endmodule

struct a
    implement b
endstruct

The following is valid for JASS but not jasshelper

Collapse JASS:
function m takes nothing returns nothing
endfunction

function d takes boolexpr b returns nothing
endfunction

function e takes nothing returns nothing
    call d(Condition(function m))
endfunction

Here is the current workaround

Collapse JASS:
function m takes nothing returns nothing
endfunction

function d takes code c returns nothing
    call Condition(c)
endfunction

function e takes nothing returns nothing
    call d(function m)
endfunction

The following is a valid object id but is not accepted by jasshelper

Collapse JASS:
function m takes nothing returns nothing
    local integer i = '\'\\34'
endfunction

The following is valid for one case and not the other

Collapse JASS:
globals
    integer integer = 5
endglobals

struct C
    unit unit = null
endstruct


The community has come up with a new allocation method that uses only 1 variable.

Collapse JASS:
struct C extends array
    private static integer array stack

    private static method allocate takes nothing returns integer
        local thistype this = stack[0]
        
        if (stack[0] == 0) then
            set stack[0] = this + 1
        else
            set stack[0] = stack[this]
        endif
        
        if (this == 8192) then
            call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,1000.,"Unable to allocate id for an object of type: C")
            return 0
        endif

        set stack[this] = -1
        
        return this
    endmethod

    private static method deallocate takes integer this returns nothing
        if this == null then
            call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,1000.,"Attempt to destroy a null struct of type: C")
            return
        elseif (stack[this] != -1) then
            call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,1000.,"Double free of type: C")
            return
        endif
        
        set stack[this] = stack[0]
        set stack[0] = this
    endmethod
    
    private static method onInit takes nothing returns nothing
        //just add this line to jasshelper__initstructs instead of ExecuteFunc
        set stack[0] = 1
    endmethod
endstruct
Nestharus is offline   Reply With Quote