Why this code doesn't work?
macro call_cosh argument
{
local a
; Detect constant
virtual
db `argument
load a byte from $$
end virtual
display '^^', a, '^^', 13, 10
if a >= '0' & a <= '9' ; It is a constant
push dword argument ; This needs to be different for better precision
if argument eqtype 1.0
fld dword [esp]
else
fild dword [esp]
end if
add esp, 4
else ; It is a variable (needs more work as this is not necessarily true)
display 13, 10, "__VARIABLE__", 13, 10
if defined argument#.float ; Why is it evaluated so early?
fld dword [esp]
else
fild dword [esp]
end if
end if
call cosh ; Argument passed in ST(0)
}
struc dd [arg]
{
common
.float:
dd arg
}
call_cosh 1.0
call_cosh 1
call_cosh alpha
call_cosh beta
alpha dd 1
beta dd 1.0
cosh: ; Not implemented
This code works and shows that "1.0" nor "1" hits the ELSE body:
macro call_cosh argument
{
local a
; Detect constant
virtual
db `argument
load a byte from $$
end virtual
display '^^', a, '^^', 13, 10
if a >= '0' & a <= '9' ; It is a constant
push dword argument ; This needs to be different for better precision
if argument eqtype 1.0
fld dword [esp]
else
fild dword [esp]
end if
add esp, 4
else ; It is a variable (needs more work as this is not necessarily true)
display "__VARIABLE__", 13, 10
if 1
fld dword [esp]
else
fild dword [esp]
end if
end if
call cosh ; Argument passed in ST(0)
}
struc dd [arg]
{
common
.float:
dd arg
}
call_cosh 1.0
call_cosh 1
call_cosh alpha
call_cosh beta
alpha dd 1
beta dd 1.0
cosh: ; Not implemented
^^1^^
^^1^^
^^a^^
__VARIABLE__
^^b^^
__VARIABLE__
[edit]It is not "defined" the problem actually, it is the ELSE block itself that gets "speculatively" evaluated when not needed[/edit]