Commit 4df636fc authored by John Spikowski's avatar John Spikowski

OXSC18121

parent 0e2db3f4
......@@ -21,6 +21,10 @@ itr 10:17 18/11/2018 Fix multiply unsigned by number (oper w1="mul ")
itr 16:07 16/11/2018 Rework rtl321 and rtl641 cats. expose char count. (catbufprp badcatl3 joinsi)
06:12 17/12/2018 Fix macro insider ## substitution (himac)
14:29 16/12/2018 Fix wide string literal binary encoding (makerecordw)
18:40 15/12/2018 Typeof returning text in chr(34) quotes (pars.inc newline)
06:04 15/12/2018 Revoke 'operator' methods & cleanup (findop)
04:27 15/12/2018 Fix Empty macro problem (replacewdt)
22:58 14/12/2018 Appe() uses copy() instead of mid()
18:37 14/12/2018 Fix "=" bug subsas (f=a)
......
......@@ -570,7 +570,7 @@ sub vars(string*s)
'
if it>=typh
k=it 'CLASS OR UDT
if ndstr=0 then hasd=findop(it,a,"destructor",dstr)
if ndstr=0 then hasd=findop(it,"destructor",dstr)
endif
endif
ws=""
......@@ -898,12 +898,8 @@ sub vars(string*s)
if (ind=0)and(hasd<>0)
wr=mrcso(me-1,1)
if not arwd then arwd="1"
'if hasd=1
' w1="_destructors(@"+wr+cm+dstr+cm+str(w)+cm+arwd+")"+cr
'else 'macro
'null variables check to be done by macro
w1=dstr+"("+w3+cm+arwd+")"+cr
'end if
'null variables check to be done by macro
w1=dstr+"("+w3+cm+arwd+")"+cr
if lclv
if asce=-1
appe(epgs[nst],epgi[nst],w1) 'no param vars
......@@ -1460,7 +1456,7 @@ sub types(int unip,vtp,*ttc,*tuc)
endif
cco=coco
if (coco=2)and(vtp=0) then coco=3
mth=dic(" ! 03, sub 01, function 02, method 03, operator 03, ",wr)
mth=dic(" ! 03, sub 01, function 02, method 03, ",wr)
'
if mth
a=len(w1)
......@@ -2600,7 +2596,7 @@ sub makeheaders(string*s,*w4,*w3, int mo)
capture(s,i,i,m)
skiplspace(s,i)
else
a=dic(" function 1, sub 2, method 3, operator 3, macro 4, ",w1)
a=dic(" function 1, sub 2, method 3, macro 4, ",w1)
if a=2
if issub(s,i)=0 then a=0 'EXCLUDE ASM SUB
endif
......
......@@ -410,9 +410,9 @@ function stodat(string*wr, int le) as string
'
if nstod=0
datc++
w1=hex(datc)
apdat "/+4 gd "
apdat w1 'ID
w1=hex(datc) 'ID SERIAL
apdat "/+4 gd "'DATA MARK
apdat w1 'ID
apdat hexl(le) 'LENGTH FIELD
apdat " "
apdat wr 'MACHINE SCRIPT CONTENT
......@@ -1852,10 +1852,14 @@ int pp=b
if asc(w1,2)=127
a=val yword(w1,3)
lenw=cv4(utfs,a)
a+=4 'byte count for pseudo-bstring
m=cv4(utfs,a)
a+=4 'start of string quote
w1=mid(utfs,a,lenw)
w1=mid(utfs,a,lenw)+" hl0" 'with terminating nulls
w1=stodat(w1,m)
else
w1=stodata(w1)
end if
w1=stodata(w1)
d=c+2
'
end select
......
......@@ -487,21 +487,6 @@ sub newcleanvar(string *wn,*wr,int p)
=====================================
wn=newtmpvar(typename(p))
wr=mrcso(me-1,1) 'vector
if p<typh
exit sub
endif
int n=mrcio(me-1,1) 'size
int mo
'string dstr
'PREP CLEANUP
'if findop(p,mo,"destructor",dstr)
' hiex+="_destructors(@"+wr+cm+
' dstr+cm+str(n)+",1)"+cr
'else
' hiex+="lea rcx,"+wr+cr+
' "mov edx,"+str(n)+cr+
' "call _nullify"+cr
'endif
end sub
......@@ -1054,14 +1039,10 @@ function compatsig(string*p1,*p2, int pb) as int
endif
elseif n>=typh 'up-convert
if uk and 2
if findop(n,a,"constructor",w1)
if findop(n,"constructor",w1)
'deferred object creation
paj(pa)=n
'if a
mpfx+=w1+"(#obj#,("+pex(pa)+")"+cr
'else
' mpfx+="#obj#.constructor("+pex(pa)+")"+cr
'endif
mpfx+=w1+"(#obj#,("+pex(pa)+")"+cr
pas(pa)="lea "+qeax+cm+"#obj#"+cr
pav(pa)=callcnvi(c,qeax,e)
k=2
......@@ -1071,22 +1052,11 @@ function compatsig(string*p1,*p2, int pb) as int
endif
endif
elseif m>=typh
'n<typh 'down-convert
if uk and 2
'if findop(m,a,"load",w1)
' 'deferred object creation
' paj(pa)=n
' mpfx+=por(pa)+".load(#obj#)"+cr
' pas(pa)=operi(1,n,"#obj#")+cr
' pav(pa)=callcnvi(c,n,e)
' k=2
' goto nxtel
'else
if (d<=48)or(e<=48)
k=0 : exit function
endif
'allow vectors to pass as floats etc
'endif
if (d<=48)or(e<=48)
k=0 : exit function
endif
'allow vectors to pass as floats etc
endif
endif
'
......
......@@ -80,7 +80,7 @@
int xmode,xoffs,opcn,lazn,tya1
string w1,w2,w3,w4,w5,w6,wr,wrp,wt,wp,laz,lazt
string ixns,wpfxa,wpfxi,wra,wri,memba,xcalc
string opsh,cpsh,wacc,waco,waccp,wacop,wrsp,hlex
string opsh,cpsh,wacc,waco,waccp,wacop,hlex
static int po[8]
static double dw=0x7fffffff
......@@ -139,19 +139,9 @@
opcall: 'subroutine
===================
'if b=0
' 'DUAL COMPATIBILITY CALL
' wt+="mov "+wrsp+",rsp"+cr+
' "sub rsp,32"+cr+
' "lea rdx,"+waco+cr+"mov [rsp+"+str(cpuw)+"],rdx"+cr+
' "lea rcx,"+wr+cr+"mov [rsp],rcx"+cr+
' "call "+w2+cr+
' "mov rsp,"+wrsp+cr
'else
'MACRO OP
hlex+=w2+"("+owa+cm+wacc+")"+cr
rps=1
'endif
'MACRO OP
hlex+=w2+"("+owa+cm+wacc+")"+cr
rps=1
skiplspace(s,i)
ret
......@@ -164,9 +154,8 @@
opsh="load"
endif
m=typ
if findop(typ,b,opsh,w2)
if findop(typ,opsh,w2)
if op<2
wrsp=tmptypvar("sys")
newcleanvar(wacc,waco,m)
endif
gosub opcall
......@@ -176,20 +165,16 @@
uex or=4096
a=1
else
ert=433 : ers="object requires operator: "+opsh
ert=433 : ers="requires operator: "+opsh
endif
ret
'
converterh: 'subroutine
=======================
if findop(m,a,"constructor",w2)
if findop(m,"constructor",w2)
m=typc
newcleanvar(owa,wr,m) 'new owa and wr
'if a
hlex+=w2+"("+owa+cm+w4")"+cr
'else
' hlex+=owa+".constructor("+w4+")"+cr
'endif
hlex+=w2+"("+owa+cm+w4")"+cr
w1=""
rps=1
endif
......@@ -404,23 +389,7 @@
'
'PRIMITIVE ACCUM
if (typx>0)and(typx<typh)
'
'POSSIBLE METHOD RETURNING PRIMITIVE?
'w3=typename(typx)
'if findop(typ,b,"primitive",w1) 'w1 dummy
' if b 'MACRO
' w2=newtmpvar(w3)
' hlex+=mrcso(typ-typh,0)+"_op.prim("+
' owa+cm+w2+")"
' w2+=" "
' rps=1
' else 'METHOD
' w2=owa+".prim()"
' endif
' inserts(s,w2,i)
' goto oploop 'reparse
'endif
ert=437 : ers=w3+" needs method: prim()"
ert=437 : ers="primitive requires conversion"
end if
'
'HIGHER OPERATION
......@@ -2503,7 +2472,7 @@
'
'HIGHER TYPE COMPARE
if typc>=typh
if findop(typc,b,cpsh,w2)
if findop(typc,cpsh,w2)
wr=wacop
owa=waccp
opsh=cpsh
......@@ -2512,7 +2481,7 @@
typa=4
goto endexpr
else
ert=433 : ers="object requires operator: "+cpsh
ert=433 : ers="requires operator: "+cpsh
goto exitexpr
endif
endif
......@@ -2588,7 +2557,7 @@
'
if hlex
if nst
if findop(typc,b,"save",w2)
if findop(typc,"save",w2)
hlex+=w2+"("+owa+cm+wacc+")"+cr
end if
endif
......
......@@ -421,7 +421,6 @@ dim 14 4
const 14 4
local 14 5
static 14 6
operator 14 7
! 14 8
declare 14 8
function 14 9
......
......@@ -180,7 +180,8 @@ isa_asm:
cmp eax,35 : jnz exit
mov eax,-11 : ret
)
mov eax,0 : ret
mov eax,0
ret
macro isxn int (r)
==================
......@@ -699,6 +700,27 @@ sub appe(string*s, int*k, string*wt)
end sub
'CONVERT TO TEXT HEX (1 LEADING SPACE)
function hexb(int v) as string
==============================
int a,b
string s=space(3)
a=v and 15
select a
case 0 to 9 : a+=48
case 10 to 15 : a+=55
end select
b=(v >> 4) and 15
select b
case 0 to 9 : b+=48
case 10 to 15 : b+=55
end select
mid(s,2)=chr(b)+chr(a)
return s
end function
string utfs 'storage for UTF-16 strings
int utfi 'buffer index (starts with 0)
'
......@@ -709,6 +731,7 @@ function ConvertUTF(string*src)
'
int i 'source byte counter
int j 'dest byte counter
int k,m 'general
int ls=len src 'source length
int lg=ls*3 'buffer length
int stt 'start offset
......@@ -720,20 +743,30 @@ function ConvertUTF(string*src)
int rp 'string record position
int le 'length of quote including quote marks
int sk 'skip flag for comments
string w1 'general
string w1,w2 'general
byte bs at strptr(src) 'source byte overlay
byte bg at strptr(dst) 'dest byte overlay
byte bt 'swapper byte
'
jmp fwd begin
'
makeRecord: 'subroutine
=======================
makeRecordW: 'subroutine
========================
rp=utfi+1 'base 1
le=j-bj-1
w1=" "+mid(dst,bj+2,le) 'full quote excluding l
appe(utfs,utfi,w1) 'included length field
mk4(utfs,rp,le) 'encode length field
le=j-bj-3
w2=mid(dst,bj+3,le) 'quote content excluding marks
w1=space(le*3)
m=1
for k=1 to le
mid(w1,m,hexb(asc(w2,k)))
m+=3
next
le=len(w1)
appe(utfs,utfi," "+w1) 'included length field
mk4(utfs,rp,le) 'length field
le=j-bj-3
mk4(utfs,rp+4,le) 'byte count field
'qu'
w1=qu+c127+str(rp)+" "+qu
mid dst,bj+1,w1
'adjust dst and j
......@@ -827,7 +860,7 @@ function ConvertUTF(string*src)
gosub nextchar8 'copy second byte
endif
wend
gosub MakeRecord
gosub MakeRecordW
continue while
endif
endif
......@@ -875,7 +908,7 @@ function ConvertUTF(string*src)
exit while
endif
wend
elseif bs=0x6c or bs=0x4c
elseif bs=0x6c or bs=0x4c 'L
if bs[2]=0x22 'double quote
bg=0x6c : bg[2]=0x22
bj=j
......@@ -888,7 +921,7 @@ function ConvertUTF(string*src)
bg=0 'append null
@bg++ : j++ 'second byte null
wend
gosub MakeRecord
gosub MakeRecordW
continue while 'main
endif 'quote
endif
......
......@@ -917,27 +917,6 @@ return v
end function
'CONVERT TO TEXT HEX (1 LEADING SPACE)
function hexb(int v) as string
==============================
int a,b
string s=space(3)
a=v and 15
select a
case 0 to 9 : a+=48
case 10 to 15 : a+=55
end select
b=(v >> 4) and 15
select b
case 0 to 9 : b+=48
case 10 to 15 : b+=55
end select
mid(s,2)=chr(b)+chr(a)
return s
end function
' CONVERT TO TEXT HEX WORD
......
......@@ -449,43 +449,26 @@ end function
function findop(int ty, *mo, string*name,*mthd) as int
======================================================
function findop(int ty, string *name,*mthd) as int
==================================================
string s,w,ts
int i,a,n,u
int i,a,n,u,f
mthd=""
mo=0
u=ty-typh
s=mrcso(u,1)
'i=instrevn(-1,s,rmk+name+" ")
'if i
' i+=len(name)+2 'skip name
' skiplspace(s,i) '
' nextspace(s,i) 'skip length
' a=readint(s,i) 'read offset
' w=mrcso(u,0)+"_table"
' n=lookupm(w)
' if n
' w=mrcso(n,1)
' mthd=memregadj(w,a) 'returning method vector
' return 1
' endif
'else 'look within _op macro for mac ops
mo=0
ts=mrcso(u,0) 'TYPE NAME
a=lookupm(ts+"_op") 'OPERATIONS GROUP NAME
if a
mthd=name
w=mrcso(a,1)
mo=instrword(w,rmk+mthd) 'LOCATE OPERATOR / FUNCTION MACROMEMBER
if mo
mthd=ts+"_op."+qu+mthd+qu
else
a=0 : mthd=""
endif
ts=mrcso(u,0) 'TYPE NAME
a=lookupm(ts+"_op") 'OPERATIONS GROUP NAME
if a
mthd=name
w=mrcso(a,1)
f=instrword(w,rmk+mthd) 'LOCATE OPERATOR / FUNCTION MACROMEMBER
if f
mthd=ts+"_op."+qu+mthd+qu
else
a=0 : mthd=""
endif
return a
'endif
endif
return a
end function
......@@ -599,6 +582,7 @@ end function
function metaval(string*s, int*i, string*wa, int tp) as double
==============================================================
'
newline=0
int a,k,n,t,o,r,igb,rcr,wtal,wtaf,opr
double b,v,w
string w1,w2,wr,wp,ws
......@@ -745,11 +729,11 @@ function metaval(string*s, int*i, string*wa, int tp) as double
endif
if nisxn
if b>2 'MATCH STRING
w1=tword(s,i)
w1=mword(s,i)
if ascn=44
i++
endif
w2=tword(s,i)
w2=mword(s,i)
if b=4
w2=left(w2,len(w1)) 'LEFTMATCH
endif
......
$ filename "c.exe"
'uses ..\rtl64
/*
'06:10 17/12/2018
'fix macro ## substitution
type tt
int a
end type
TYPE UDT1
CHAR x[12]
END TYPE
MACRO SOMEMACRO(a)
print a.x
END MACRO
'#recordof somemacro
UDT1 u1[100]={"okm"}
somemacro u1[1]
'somemacro
print "ok"
macro mm(v)
tt v
print "x"#v#""
v.a=1
end macro
'
mm
*/
/*
'/*
'concatenation operations
'13:07 14/12/2018
'
type cat
sys bu
int le
end type
class cat
=========
string s
sys ls,i
'
function str() as string
return left s,i
end function
function add(sys p,le)
if le+i>ls
s+=nuls le+0x1000
ls+=le+0x1000
endif
copy i+strptr s,p,le
i+=le
end function
end class
def sh ` %1 `
macro cat_op(a,b)
=================
'
macro .load(a,b)
print "load " sh a sh b
print "load " sh a sh b
b.i=0
#if match "cat",typeof a
b.add(strptr(a.s),a.i))
#else
b.add(strptr(a),len(a))
#endif
end macro
'
macro .save(a, b)
print "save " sh a sh b
macro .+ (a,b)
print "+ " sh a sh b " " typeof a
#if match typeof a,"cat"
print "another cat"
b.add(strptr(a.s),a.i)
#else
b.add(strptr(a),len(a))
#endif
end macro
'
macro .+ (a,b)
print "+ " sh a sh b
macro .destructor(a,n, p,i)
print "destructor "#a#""
int i
cat p at @a
for i=1 to n
p.s=""
@p+=sizeof a
next
end macro
'
macro .+= (a,b){} 'dummy to flag operation as accumulator
macro .+= ()
end macro
'
end macro
end macro 'cat
cat c
cat d
'c="A"
'c+="A"
print typecodeof " "
'print typeof " "
typeof "" s
print typecodeof s
'c+="A" "B"
c+=d
print "ok"
'*/
/*
'04:49 17/12/2018
'wide string support
#show wstring s=l"ok"
print s
*/
......
No preview for this file type
......@@ -503,7 +503,9 @@ function HiMac(int mm, string*s, int*i) as string
'
a=0
'
if nisxn
if isxn
w2=w4
else
a=1
if ascn=47
i++ : c+=1024 'INHIBIT CREATION OF WV RETURN VAR
......@@ -518,10 +520,7 @@ function HiMac(int mm, string*s, int*i) as string
i++ : nextinstruct(s,i)
endif
'
'
if a
replacewd(w1,w4,w2,1) 'REPLACE W4 WITH W2 IN BODY W1
endif
replacewd(w1,w4,w2,1) 'REPLACE W4 WITH W2 IN BODY W1
itm++
c++
if c=1
......@@ -1506,7 +1505,7 @@ function attributes(string s, int *i) as string
if nl
typ=0 'raw code
else
wr=iq+wr+iq 'quoted string literal
wr=qu+wr+qu 'quoted string literal
typ=0xc1
endif
'
......@@ -2217,8 +2216,13 @@ function mword(string*s, int*i ) as string
'
if qot
mc=-32
typ=0xc1
sog="bstring"
if asc(wr,2)=127
typ=0xc2
sog="bstring2"
else
typ=0xc1
sog="bstring"
end if
goto exitmword1
endif
'
......
......@@ -5,105 +5,8 @@
! PrepExec() as string
string Util,Utilh
'
/*
string Utilh="
! sub _destructors(sys b,d,z,n)
! function isnull(sys p, int n) as int
"
string Util="
jmp fwd over
_nullify:
=========
'rcx base
'edx count
'
mov rax,rcx 'return base address
(
cmp edx,0
jg exit
ret
)
(
mov byte [rcx],0
inc rcx
dec edx
jg repeat
)
ret
'
_isnull:
========
'rcx base
'edx count
(
cmp rdx,0
jg exit
mov eax,1
ret
)
(
cmp byte [rcx],0
jnz exit
inc rcx
dec edx
jg repeat
mov eax,1
ret
)
mov eax,0
ret
string Util,Utilh 'common runtime routines
'
over:
'
'
sub _destructors(sys b,d,z,n)
=============================
sys i
sys s
int t
'dual 32/64 direct
for i=1 to n
mov rcx,b
mov rdx,z
call _isnull
mov t,eax
if not t
mov s,rsp
sub rsp,32
mov rcx,b
mov [rsp],rcx
call d
'mov rsp,s
'mov rcx,b
'mov edx,z
'call _nullify
end if
b+=z
next
end sub
'
function isnull(sys p, int n) as int
====================================
mov rcx,p
mov edx,n
call _isnull
return
end function
function nullify(sys p,int n)
=============================
mov rcx,p
mov edx,n
call _nullify
end function
" 'end Util
*/
function dimtype(string*s, int*i) as string
......@@ -653,7 +556,6 @@ end function
' ttc class table entries tally
' tuc class tabel inherited entries
' wfn function / sub / method
' opss operator string
' shf #show filename
' shs #show source line
' dfv default value flag for prototypes
......@@ -672,7 +574,7 @@ end function
int relaxed=0
string w1,w2,w3,w4,w5,w6,w7,w8,w9,wd,wm,wn,wr,ws,wt,wv,s
string ali,lby,prf,mage,wc,sw,wfn,opss,shf,shs
string ali,lby,prf,mage,wc,sw,wfn,shf,shs
'==============
......@@ -1304,14 +1206,14 @@ end function
'
if typm>=typh
asg=""
if findop(typm,a,"save",w2)
if findop(typm,"save",w2)
loadh="save"
else
loadh="load"
endif
if cpa>2
w3=wr+"="
if findop(typm,a,w3,w2)
if findop(typm,w3,w2)
'using osg as accumulator
'optimisation for concatenators
jmp fwd expract
......@@ -1353,15 +1255,11 @@ end function
goto cleardown 'address assign etc
endif
endif
if findop(typg,a,loadh,w2)
if findop(typg,loadh,w2)
w1=epfx+w1 : epfx=""
hiex+=storecode(w1)
rps=16
'if a then
hiex+=w2+"("+accg+cm+osg+")"+cr