Author Topic: PluriBASIC - Progress March 7 2018  (Read 494 times)

0 Members and 1 Guest are viewing this topic.

Offline Brian Alvarez

  • Moderator
  • Newbie
  • *****
  • Posts: 36
PluriBASIC - Progress March 7 2018
« on: March 08, 2018, 03:58:28 AM »
 Until now, the engine could compile 64 bit applications with no problems. However since the engine was using plain "string" strings, the calls to external DLL's crashed.

 Today i decided to make a big step and started implementing BSTR as the default string type.

 It is a challenge because now the engine must do much more to compare, concatenate and in general, handle the strings.

 The benefits are that PluriBASIC will support Unicode, as well as being compatible with external DLL's and producing highly compatible DLLs and C++ SLLs, aka LIBs.

 When i finish this, i would like to handle the array order to handle the params backwards. If you know what i mean. This will increase the compatibility with external stuff.

Brian. :)
« Last Edit: March 08, 2018, 04:01:56 AM by Brian Alvarez »

Offline Brian Alvarez

  • Moderator
  • Newbie
  • *****
  • Posts: 36
Re: PluriBASIC - Progress March 7 2018
« Reply #1 on: March 09, 2018, 12:57:16 AM »

Done. The engine now uses BSTR's. Yay!

Offline Brian Alvarez

  • Moderator
  • Newbie
  • *****
  • Posts: 36
Re: PluriBASIC - Progress March 7 2018
« Reply #2 on: March 09, 2018, 12:58:23 AM »
The string data types supported are:

STRING  (BSTR)
STRINGZ (char)
WSTRING (BSTR)
WSTRINGZ  (wchar_t)
ASCIIZ (LPSTR)

 They all interact correctly when compared and concatenated.

:)

Offline Theo Gottwald

  • Administrator
  • Hero Member
  • *****
  • Posts: 1117
  • Gender: Male
    • it-berater
Re: PluriBASIC - Progress March 7 2018
« Reply #3 on: April 07, 2018, 07:26:58 AM »
Sounds good!
Can you cooperate with other programmers who are working on such projects - for example
- Charles Pegge (Oxygen)
- James C. Fuller (bc9Basic)
such a Cooperation would speed up things significantly. Especially as you come now to the part where you need to be compatible
with APIs, DLL's from other Languiages and such.

Offline Chris Chancellor

  • Newbie
  • *
  • Posts: 7
Re: PluriBASIC - Progress March 7 2018
« Reply #4 on: April 17, 2018, 12:28:21 AM »
Brian,  this  O2 Charles Pegge is a maestro and he can help out on your project.

You should register as a member in oxygen basic and see what you can come up with a better product 

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 737
    • Charles Pegge
Re: PluriBASIC - Progress March 7 2018
« Reply #5 on: April 17, 2018, 10:24:19 AM »

I would warmly welcome any compiler development that needs a back-end. Oxygen.dll (141kb) provides all-in-one basic compiling, assembly and linkage, both for PE files and direct JIT execution. The benefit to the Oxygen party would be to establish the best protocols and techniques for creating new compilers :)

The core functions are the minimum required for BASIC, and uses ole strings, like PowerBasic and thinBasic.

It is quite easy to add extensions and specialised syntax such as DDT, which can be decomposed into standard procedures.

As an example, here is our current co2 compiler source (4k), using oxygen.dll.

Code: [Select]

 'Compiler for OxygenBasic
 '========================

 'Charles Pegge
 '12:53 11/06/2015
 '10:17 06/03/2017
 '15:26 13/01/2018

  #compact
  #file "co2.exe" 'Oxygen dependent compiling
  %NoConsole
  uses SysUtil
  uses console

  extern lib "oxygen.dll"
  uses oxygenAPI
  end extern

  BufferObject 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: o2 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
  '
  er=o2_error
  '
  if er then
    pr.in cr+ er
    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

Offline Brian Alvarez

  • Moderator
  • Newbie
  • *****
  • Posts: 36
Re: PluriBASIC - Progress March 7 2018
« Reply #6 on: April 17, 2018, 02:16:04 PM »

 Hello Charles, what is oxigen? The syntax looks very different to what i am aiming to...
Can you ellaborate?

 By the way, i already implemented ARRAY SORT. Im very close to compiling PluriBASIC in itself as a 64 bit compiler.

Offline Charles Pegge

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 737
    • Charles Pegge
Re: PluriBASIC - Progress March 7 2018
« Reply #7 on: April 17, 2018, 04:27:28 PM »
Hi Brian,

Oxygen understands the Qbasic/PB genre of Basic syntax, but has additional flexibility, including C notation. It could replace any dependencies on PB or a C compiler at the back-end.

Offline Chris Chancellor

  • Newbie
  • *
  • Posts: 7
Re: PluriBASIC - Progress March 7 2018
« Reply #8 on: April 17, 2018, 05:45:54 PM »
Hello Brian

PB commands can  be converted directly to Oxygenbasic O2 commands and then  be compile to 64bit exe and dll assemblies

and that O2 also allow for inline assembly which has all the features of PB inline assembly codes.

see the http://www.oxygenbasic.org/forum/index.php
for yourself

and download its latest compiler and sample from
https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenBasicProgress.zip


Offline Brian Alvarez

  • Moderator
  • Newbie
  • *****
  • Posts: 36
Re: PluriBASIC - Progress March 7 2018
« Reply #9 on: April 17, 2018, 08:39:27 PM »

 PluriBASIC is prepared to output code for any platform. So, even if i added an Oxigen mode, i would still like to finish the C++ version.
I also know Qbasic, maybe that will help. I will take a look when i have the chance. :)