Commit e9497bff authored by John Spikowski's avatar John Spikowski

O2 Sandbox Initial Commit

parent 68509bb2
del co2???.exe
del oxygen??.dll
copy oxygen.dll ..\..\oxygen.dll
pause
\ No newline at end of file
'JIT Compile
============
'
extern lib "oxygenC.dll"
'compact api
! o2_mode (int m)
! o2_buf (int i) as sys
! o2_basic(string s)
! o2_errno() as int
! o2_error() as string
! o2_exec(sys p) as sys
end extern
'
extern
'
string s
'
s=quote """
'
print version
extern
'
sub finish()
terminate
end sub
'
function fa() as sys
print "helo"
end function
'
function fb() as sys
print "bye!"
end function
'
'
sys table={@finish,@fa,@fb}
@table
'
"""
'
o2_mode 9 'ascii string (1: byte characters) (8: ole string)
o2_buf 1
o2_basic s 'COMPILE
'
sys p
string r
'
if o2_errno then
r=o2_error()
mbox r
jmp fwd done
else
p=o2_exec 0
end if
if not p then jmp fwd done
sys tf at p
! hello at tf[2]
! bye at tf[3]
! fin at tf[1]
print version
hello()
bye()
fin()
'
done:
'
end extern
copy ..\..\oxygen1.dll ..\..\oxygen.dll
pause
\ No newline at end of file
'Compiler for OxygenBasic
'========================
'Charles Pegge
'12:53 11/06/2015
'10:17 06/03/2017
'15:26 13/01/2018
'00:35 26/08/2018
#compact
$ Filename "co2.exe"
uses RTL32
%NoConsole
uses SysUtil
uses console
extern lib "oxygen32.dll"
uses oxygenAPI
end extern
Buffer pr
sys a,i
string s,t,u
sys swa,swc,swm 'COMPILER SWITCHES
string fname,mname,xname '1st FILE NAME COMPONENTS
string bfname,bmname,bxname '2nd FILE NAME COMPONENTS
string er 'ERROR MESSAGES
'
s=lcase CommandLineArgs()
if not s then goto nofile
'
'SWITCHES
'========
i=0
do
i++ : skiplspace s,i
if ascb<>45 then exit do
i++ : skiplspace s,i
select ascb
case "i" : swa=ascb '-i intermediate output
case "a" : swa=ascb '-a asm output
case "b" : swa=ascb '-b o2 output
case "c" : swc=ascb '-c compile
case "m" : swm=ascb '-m do not show messagebox
end select
end do
'
s=mid s,i
'
nofile: 'check
'=============
'
if not s then
pr.in "
compiler options:
<filename> compile and execute directly in memory
-a <filename> list assembly code
-b <filename> list o2 machine script
-c <filename> <optional filename> compile to a binary
-i <filename> list intermediate code
-m output to console
"
jmp fwd done
end if
'
'GET FILENAMES
'=============
'
i=1 : xname=".o2bas" 'DEFAULT SOURCE EXTENSION NAME
fname=ParseFileName(s,i,mname,xname)
bxname=".exe"'DEFAULT BINARY EXTENSION NAME
bfname=ParseFileName(s,i,bmname,bxname)
'
'
'ATTEMPT TO GET FILE
'===================
'
t=getfile fname
if not t then
pr.in "error 3: file empty or not found: "+fname
jmp fwd done
end if
'
u=""
'
if swc then
if bfname="" then
bfname=mname+".exe"
end if
u+="#file "+qu+bfname+qu+cr
end if
'
t=u+chr(12)+t
'
'
'NORMAL COMPILE
'==============
'o2_mode 0 'read/return null terminated ascii strings
o2_mode 9 'ascii string (1: byte characters) (8: ole string)
'
select swa
case "a" : pr.in o2_prep(t) 'OUTPUT ASSEMBLY CODE
case "b" : pr.in o2_view(t) 'OUTPUT O2 MACHINE SCRIPT (AFTER ASSEMBLY CODE)
case "i" : pr.in o2_abst(t) 'OUTPUT INTERMEDIATE CODE (BEFORE ASSEMBLY CODE)
case else : o2_basic t 'COMPILE TO EXECUTABLE BINARY
end select
'
if o2_errno then
pr.in cr+o2_error()
jmp fwd done
else
if swc=0 then
o2_exec 0
else
pr.in cr+"Okay"
end if
end if
done:
'DISPLAY RESULTS
sys ho,lew
string prs=pr.out
if len(prs) then
if swm=0 then
mbox prs
else
'sys p=GetCurrentProcess() '-1 parent process
AttachConsole(-1) 'attach to console of parent process
output prs
sys ho=GetStdHandle( STD_OUTPUT_HANDLE )
if ho<>consout then consout=ho : output prs 'windows 10
sleep 10
FreeConsole
end if
end if
$dll
$filename "oxygen.dll"
uses RTL32
uses main
$dll
$filename "oxygen32.dll"
uses RTL32
uses main
$dll
$filename "oxygen64.dll"
uses RTL64
uses main
'Compiler for OxygenBasic
'========================
'Charles Pegge
'12:53 11/06/2015
'10:17 06/03/2017
'15:26 13/01/2018
'00:35 26/08/2018
#compact
'#file "co2.exe" 'Oxygen dependent compiling
$ Filename "co2m32.exe"
uses RTL32
%NoConsole
includepath "..\"
uses SysUtil
includepath ""
uses console
extern lib "oxygen32.dll"
includepath "..\"
uses oxygenAPI
includepath ""
end extern
Buffer pr
sys a,i
string s,t,u
sys swa,swc,swm 'COMPILER SWITCHES
string fname,mname,xname '1st FILE NAME COMPONENTS
string bfname,bmname,bxname '2nd FILE NAME COMPONENTS
string er 'ERROR MESSAGES
'
s=lcase CommandLineArgs()
s="o2tests.o2bas"
if not s then goto nofile
'
'SWITCHES
'========
i=0
do
i++ : skiplspace s,i
if ascb<>45 then exit do
i++ : skiplspace s,i
select ascb
case "i" : swa=ascb '-i intermediate output
case "a" : swa=ascb '-a asm output
case "b" : swa=ascb '-b o2 output
case "c" : swc=ascb '-c compile
case "m" : swm=ascb '-m do not show messagebox
end select
end do
'
s=mid s,i
'
nofile: 'check
'=============
'
if not s then
pr.in "
compiler options:
<filename> compile and execute directly in memory
-a <filename> list assembly code
-b <filename> list o2 machine script
-c <filename> <optional filename> compile to a binary
-i <filename> list intermediate code
-m output to console
"
jmp fwd done
end if
'
'GET FILENAMES
'=============
'
i=1 : xname=".o2bas" 'DEFAULT SOURCE EXTENSION NAME
fname=ParseFileName(s,i,mname,xname)
bxname=".exe"'DEFAULT BINARY EXTENSION NAME
bfname=ParseFileName(s,i,bmname,bxname)
'
'
'ATTEMPT TO GET FILE
'===================
'
t=getfile fname
if not t then
pr.in "error 3: file empty or not found: "+fname
jmp fwd done
end if
'
u=""
'
if swc then
if bfname="" then
bfname=mname+".exe"
end if
u+="#file "+qu+bfname+qu+cr
end if
'
t=u+chr(12)+t
'
'
'NORMAL COMPILE
'==============
'o2_mode 0 'read/return null terminated ascii strings
o2_mode 9 'ascii string (1: byte characters) (8: ole string)
'
select swa
case "a" : pr.in o2_prep(t) 'OUTPUT ASSEMBLY CODE
case "b" : pr.in o2_view(t) 'OUTPUT O2 MACHINE SCRIPT (AFTER ASSEMBLY CODE)
case "i" : pr.in o2_abst(t) 'OUTPUT INTERMEDIATE CODE (BEFORE ASSEMBLY CODE)
case else : o2_basic t 'COMPILE TO EXECUTABLE BINARY
end select
'
if o2_errno then
pr.in cr+o2_error()
jmp fwd done
else
if swc=0 then
o2_exec 0
else
pr.in cr+"Okay"
end if
end if
done:
'DISPLAY RESULTS
sys ho,lew
string prs=pr.out
if len(prs) then
if swm=0 then
mbox prs
else
'sys p=GetCurrentProcess() '-1 parent process
AttachConsole(-1) 'attach to console of parent process
output prs
sys ho=GetStdHandle( STD_OUTPUT_HANDLE )
if ho<>consout then consout=ho : output prs 'windows 10
sleep 10
FreeConsole
end if
end if
'Compiler for OxygenBasic
'========================
'Charles Pegge
'12:53 11/06/2015
'10:17 06/03/2017
'15:26 13/01/2018
'00:35 26/08/2018
#compact
$ Filename "co2m64.exe"
uses RTL64
%NoConsole
includepath "..\"
uses SysUtil
includepath ""
uses console
extern lib "oxygen64.dll"
includepath "..\"
uses oxygenAPI
includepath ""
end extern
Buffer pr
sys a,i
string s,t,u
sys swa,swc,swm 'COMPILER SWITCHES
string fname,mname,xname '1st FILE NAME COMPONENTS
string bfname,bmname,bxname '2nd FILE NAME COMPONENTS
string er 'ERROR MESSAGES
'
s=lcase CommandLineArgs()
s="o2tests.o2bas"
if not s then goto nofile
'
'SWITCHES
'========
i=0
do
i++ : skiplspace s,i
if ascb<>45 then exit do
i++ : skiplspace s,i
select ascb
case "i" : swa=ascb '-i intermediate output
case "a" : swa=ascb '-a asm output
case "b" : swa=ascb '-b o2 output
case "c" : swc=ascb '-c compile
case "m" : swm=ascb '-m do not show messagebox
end select
end do
'
s=mid s,i
'
nofile: 'check
'=============
'
if not s then
pr.in "
compiler options:
<filename> compile and execute directly in memory
-a <filename> list assembly code
-b <filename> list o2 machine script
-c <filename> <optional filename> compile to a binary
-i <filename> list intermediate code
-m output to console
"
jmp fwd done
end if
'
'GET FILENAMES
'=============
'
i=1 : xname=".o2bas" 'DEFAULT SOURCE EXTENSION NAME
fname=ParseFileName(s,i,mname,xname)
bxname=".exe"'DEFAULT BINARY EXTENSION NAME
bfname=ParseFileName(s,i,bmname,bxname)
'
'
'ATTEMPT TO GET FILE
'===================
'
t=getfile fname
if not t then
pr.in "error 3: file empty or not found: "+fname
jmp fwd done
end if
'
u=""
'
if swc then
if bfname="" then
bfname=mname+".exe"
end if
u+="#file "+qu+bfname+qu+cr
end if
'
t=u+chr(12)+t
'
'
'NORMAL COMPILE
'==============
'o2_mode 0 'read/return null terminated ascii strings
o2_mode 9 'ascii string (1: byte characters) (8: ole string)
'
select swa
case "a" : pr.in o2_prep(t) 'OUTPUT ASSEMBLY CODE
case "b" : pr.in o2_view(t) 'OUTPUT O2 MACHINE SCRIPT (AFTER ASSEMBLY CODE)
case "i" : pr.in o2_abst(t) 'OUTPUT INTERMEDIATE CODE (BEFORE ASSEMBLY CODE)
case else : o2_basic t 'COMPILE TO EXECUTABLE BINARY
end select
'
if o2_errno then
pr.in cr+o2_error()
jmp fwd done
else
if swc=0 then
o2_exec 0
pr.in "done exec64" cr
else
pr.in cr+"Okay"
end if
end if
done:
'DISPLAY RESULTS
sys ho,lew
string prs=pr.out
if len(prs) then
if swm=0 then
mbox prs
else
'sys p=GetCurrentProcess() '-1 parent process
AttachConsole(-1) 'attach to console of parent process
output prs
sys ho=GetStdHandle( STD_OUTPUT_HANDLE )
if ho<>consout then consout=ho : output prs 'windows 10
sleep 10
FreeConsole
end if
end if
*.inc
*.txt
*.o2bas
..\rtl*.inc
-r ..\*.inc
-r ..\..\*.o2bas
-r ..\..\*.exe
-r ..\..\*.dll
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
c:\cevp\code\upx --brute oxygen.dll
rem c:\cevp\code\upx --brute o2g2.exe
rem c:\cevp\code\upx --brute --force o2g1.exe
pause
\ No newline at end of file
c:\cevp\code\upx --force --brute oxygen64.dll
pause
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
# OxygenBasic
BASIC compiler. Run programs directly, or compile to 32/64 bit binary. Supports C headers and assembly code.
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment