|
'---------------
'MACRO OPERATORS
'===============
'PARTIAL DEMO
type vector3f
float x,y,z
end type
macro vector3f_op(out,in1,in2)
macro ."load"(in1)
end macro
macro ."save"(out,in1)
out.x = in1.x
out.y = in1.y
out.z = in1.z
end macro
macro ."neg"(out,in1)
out.x = -in1.x
out.y = -in1.y
out.z = -in1.z
end macro
macro ."+"(out,in1,in2)
out.x = in1.x + in2.x
out.y = in1.y + in2.y
out.z = in1.z + in2.z
end macro
macro ."-"(out,in1,in2)
out.x = in1.x - in2.x
out.y = in1.y - in2.y
out.z = in1.z - in2.z
end macro
macro ."*"(out,in1,in2)
out.x = in1.x * in2.x
out.y = in1.y * in2.y
out.z = in1.z * in2.z
end macro
macro ."/"(out,in1,in2)
out.x = in1.x / in2.x
out.y = in1.y / in2.y
out.z = in1.z / in2.z
end macro
'
macro ."=" bool (out,in1,in2) 'LOGICAL / COMPARATORS
scope
double v1 = in1.x*in1.x + in1.y*in1.y + in1.z*in1.z
double v2 = in2.x*in2.x + in2.y*in2.y + in2.z*in2.z
if v1=v2 then out = 1
end scope
end macro
'
macro .">" (out,in1,in2) 'LOGICAL / COMPARATORS
scope
double v1 = in1.x*in1.x + in1.y*in1.y + in1.z*in1.z
double v2 = in2.x*in2.x + in2.y*in2.y + in2.z*in2.z
if v1>v2 then out = 1
end scope
end macro
'
macro ."str" string (out,in1) 'CORE FUNCTIONS
out=str(in1.x)+","+str(in1.y)+","+str(in1.z)
end macro
'
end macro
'TESTS
#recordof "r.txt" vector3f_op
dim vector3f A = {1,2,3}
dim vector3f B = {10,20,30}
dim vector3f M = {10,100,1000}
'print str(A)
'print str(A+B)
'print str(M*(A+B))
'if B>A then
' print "B>A: " str(B)
'else
' print "A>=B: " str(A)
'end if
dim vector3f C,D
'D=B
'#show D=A+B
'if B>A
' D=B
'else
' D=C
'end if
'D.y = ( A.y > B.y ? B.y : A.y )
'D.y = ( A.y > B.y ? B.y : A.y )
'D.y = ( A>B ? B.y : A.y )
'D.y = ( B>A ? B.y : A.y )
'D = ( A.y > B.y ? B : A )
'D = ( B.y > A.y ? B : A )
'D = ( A>B ? B : A )
'#show D = ( B>A ? B : A )
'D = ( B>A ? B+A : B-A )
D = ( A>B ? B+A : B-A )
print str(D)
|