- Joined
- Feb 6, 2014
- Messages
- 2,466
I tried testing it, the code is:
And the generated JASS script is:
However
And if you can see, I got DEBUG_MODE disabled because it was able to inline a function. So does this mean constant variables doesn't get inlined and the inlining mentioned in the JassHelper Manual is false?
However when dealing with
JASS:
library L initializer F
globals
constant integer INT1 = 42
constant integer INT2 = 42 + 73
constant real REAL1 = 2.718281828
constant real REAL2 = 1/32
constant real REAL3 = SquareRoot(5)
constant real REAL4 = Pow(2, 128)
constant boolean BOOL = true
constant player PLAYER = Player(14)
endglobals
function Inline takes nothing returns real
return 42.0
endfunction
function F takes nothing returns nothing
local integer i = INT1 + INT2
local real r = REAL1 + REAL2 + REAL3 + REAL4
local player p = PLAYER
if BOOL then
set r = Inline()
endif
endfunction
endlibrary
And the generated JASS script is:
JASS:
globals
//globals from L:
constant boolean LIBRARY_L=true
constant integer INT1= 42
constant integer INT2= 42 + 73
constant real REAL1= 2.718281828
constant real REAL2= 1 / 32
constant real REAL3= SquareRoot(5)
constant real REAL4= Pow(2, 128)
constant boolean BOOL= true
constant player PLAYER= Player(14)
//endglobals from L
// Generated
trigger gg_trg_Inlining= null
trigger l__library_init
//JASSHelper struct globals:
endglobals
//library L:
function Inline takes nothing returns real
return 42.0
endfunction
function F takes nothing returns nothing
local integer i= INT1 + INT2
local real r= REAL1 + REAL2 + REAL3 + REAL4
local player p= PLAYER
if BOOL then
set r=(42.0) // INLINED!!
endif
endfunction
//library L ends
However
JassHelper Manual said:Global declaration freedom simply allows you to write globals blocks wherever you want, for example in the custom script section or in a 'trigger', and because of this you can even use the constant prefix which can even make finalizers able to inline constants and stuff.
And if you can see, I got DEBUG_MODE disabled because it was able to inline a function. So does this mean constant variables doesn't get inlined and the inlining mentioned in the JassHelper Manual is false?
However when dealing with
static if
, the constant boolean are pre-evaluated upon compilation of the script so it doesn't make sense not to inline the constants. Perhaps I'm doing something wrong here?