Mintoris
Oct 20, 2017, 12:32 PM *
Welcome, Guest.

login

register

Did you miss your activation email?


Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1] 2
  Print  
Author Topic: Basic Version 8  (Read 1985 times)
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« on: Jan 02, 2017, 01:24 PM »

Mintoris Basic Pro Version 8 is now in production. This version is an almost complete rewrite of the Basic compiler and runtime. There have been great improvements in speed and efficiency. The compiler rewrite is a big part of the speed increases. A lot of work has been moved from the runtime to the compiler, doing things ahead of time as not to slow down the runtime.

The new compiler is much more thorough than the old compiler. It checks many things that just slipped by the old compiler. It checks that each For has a Next, each Do has a Loop.

It also checks that each Sub has a matching End Sub. Sub and End Sub are a matched set. You can't have one without the other. The old compiler allowed any combination of commands that you like and relied on the runtime to find any problems.

The following code fragments would cause a compile error with Version 8.

sub norm(n)
  nm=n - 360 * floor(n / 360)
return nm


That would be a Sub without matching End Sub.


This is a End Sub without matching Sub

Gosub backstars
end

backstars:
  
End Sub


I've attached a new listing file that is output by the compiler.
« Last Edit: Jan 02, 2017, 11:40 PM by Chuck » Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #1 on: Jan 16, 2017, 08:01 PM »

Basic is morphing from recursion to stack oriented processing. With the recursion gone I will be able to pause execution at any time. This includes within a function that returns a value as well as a stepping debugger. Also, the recursion depth limit on functions will go from 10-20 deep to nearly bottomless. Only limited by memory. The compiler rewrite is nearly complete and the runtime kernel rewrite is all planned out. Version 8 will be a completely different program under the hood. There will be an automatic recompile of all older code.
Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #2 on: Jan 18, 2017, 11:32 PM »

In version 8, command parameters will be evaluated right to left instead of left to right. Color 3, 2, 1 Blaine the Pain said, "This pump primes backwards."


The screenshot below is the decompiled iCode output from the new compiler.
Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #3 on: Jan 19, 2017, 08:36 PM »

First day of runtime work complete. Soon I'll get to execute my backwards iCode.
I've laid out the new variable types:

boolean b = true
byte b = 255
char c = 1024
int i = -1024
long timer = time()
float f = 1.5
double d = 1.5 <-- (default)
BigInteger bigI = "10000000000000000"
BigDecimal bigd = ".00000000000000000000001"
String s$ = "Hello"
Object bitmap = createBitmap(100, 100)

plus array versions of each.

I believe I have a very efficient way to mix variable types with errors for over/under flow.
Logged
steven
Jr. Member
**
Posts: 7


« Reply #4 on: Jan 28, 2017, 01:53 PM »

Any eta when version 8 will be released?

It will be a free upgrade correct?
Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #5 on: Jan 28, 2017, 07:13 PM »

Yes, updates are always free. With the amount of work I still have to do, hate to put a firm date on it. Maybe sometime in April.

Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #6 on: Jan 30, 2017, 11:44 PM »

I just got the first program to run since the rewrite

print "Hello World"
a = 1
print a

The iCode looks perfect. RPN is awesome. Running on a background thread, it's now impossible to lock up the app with a Basic program.
Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #7 on: Jan 31, 2017, 09:33 PM »

Addition, subtraction, multiplication, division and a couple others are working. No loops or if statements yet. Things will begin to move faster now that the new boiler plate is almost in place. Most of the commands and functions will run unchanged from the prior 7.5 version.
Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #8 on: Feb 01, 2017, 05:34 PM »

In the end even the iCode had to go. As the iCode is read into the runtime it is converted into a series of java objects. After loading, the iCode is never used again. Your program then consists of these java objects (Operon(s)) that just interact with one another to run your program. So, in Version 8 at runtime, your code is running 100% java bytecode. If you are running Android Marshmallow or later you are running 100% machine code optimized for your particular device.
Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #9 on: Feb 06, 2017, 09:54 PM »

All the operators are now working. This includes all the new ones like
x += 5, x++, x--, ++x, --x. You will also be able to use expressions as parameters x = abs(y = x + 5). I've spent a lot of time refining the new code. We are doing speed tests now. We know it's faster than the current live version, but not sure how much faster. At least 3x.
Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #10 on: Feb 08, 2017, 05:52 PM »

All the new variable types are in and being tested.

Code:
boolean b = true
byte y = 255
char c = 1024
int i = -1
long l = time()
Float f = 1.5
Double d = 1.5
BigInteger bi = time()
BigDecimal bd = 100.01
Complex cm = "3 + 4i"

print b
print y
print c
print i
print l
print f
print d
print bi
print bd
print cm

print boolean(true)
print byte(255)
print char(1024)
print int(-1)
print long(time())
print float(1.5)
print double(1.5)
print BigInteger(time())
print BigDecimal(100.01)
print complex("3 + 4i")

The new conditional equal sign rule:

A single equal sign in an if-then, while or until statement, will be taken as a conditional equal.
If the new conditional equal operator == is used in an if-then, while or until, any single equal signs are taken as assignment equal signs.

In all other situations the single equal sign is taken as an assignment and the new == conditional equal can be used to specify a condition going forward.
« Last Edit: Feb 08, 2017, 06:17 PM by Chuck » Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #11 on: Feb 09, 2017, 08:12 PM »

We've got all these new variable types. Any variable name can be made any variable type. I've generalized things so much that the following things will work.

String A = "Hello"

A is now a string.

if A is uninitialized

A = "Hello"

will make A a string.

The reverse is also true for variables that end in a dollar sign A$. At runtime I can't tell if a variable has a $ at the end. It's just a variable reference at that point. What, if anything, should I do about this?

I'm not saying this is the way things should work, they just do work this way. I'm not really making up these rules. They formed as a logical extension of RPN and the way I designed the variable classes.
Logged
talun
Jr. Member
**
Posts: 7


« Reply #12 on: Feb 20, 2017, 12:42 AM »

Chuck, many thanks for the future improvements to the compiler. Can you say if there will be also the functions for writing and reading these new data type to binary files?

Thanks!

Sergio
Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #13 on: Feb 20, 2017, 09:06 AM »

Chuck, many thanks for the future improvements to the compiler. Can you say if there will be also the functions for writing and reading these new data type to binary files?

I am still thinking about file IO. The Load/SaveCode$() functions already work with all the new data types. I am considering a packData() and unpackData() which will work like Load/SaveCode$(), but with binary compression of the data.
Logged
talun
Jr. Member
**
Posts: 7


« Reply #14 on: Feb 21, 2017, 01:10 AM »

Chuck,
   many thanks for your reply; just a curiosity since I'm not at all an expert of compilers: it is very difficult to create routines for file  IO of the different types of  data such as example ReadLong, WriteLong, ReadDouble etc. etc.?

bye

Sergio
Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #15 on: Feb 21, 2017, 11:24 PM »

I've been expanding everything to take advantage of the new variable types. I expect file IO will be the same when I get to it.
« Last Edit: Feb 21, 2017, 11:35 PM by Chuck » Logged
talun
Jr. Member
**
Posts: 7


« Reply #16 on: Feb 23, 2017, 09:47 AM »

Thanks!

bye

Sergio
Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #17 on: Feb 23, 2017, 08:33 PM »

Did I mention that all the data types automatically convert to one another as needed seamlessly and automatically. This new Basic loves mixed expressions, unless you exceed a variable's type limit. Then you get an error.

New inline entry for hex, octal and binary. Also strings with the following numeric format will automatically convert to any of the data types.

byte x = 0xff
char y = 0c77
int z = 0b10101010

int s = "0xff"
« Last Edit: Feb 23, 2017, 08:58 PM by Chuck » Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #18 on: Apr 17, 2017, 06:26 PM »

I just finished adding a new graphics command which will allow you to buffer drawing commands to be drawn automatically right after a cls (clear screen). This is for the regular graphics mode.

Code:
Graphics on

DrawingBuffer on
color 0,0,100,100
cls
color 100,0,0,100
line 0,0,screenX(), screenY()

DrawingBuffer off

Now whenever you clear the screen the buffered drawing commands are automatically drawn in for you at high speed.

Then you can enter your draw loop and do animation or whatever over the pre-drawn background.

Expect this in Version 8.
Logged
Chuck
Global Moderator
Hero Member
*****
Posts: 1837



« Reply #19 on: Apr 20, 2017, 08:58 PM »

Can you guess what SetDrawingBufferOffest offsetX, offsetY does?

Code:
' ********************
' ** Analoge Clock  **
' **    (C) 2011    **
' ** Thomas Krueger **
' ********************

GRAPHICS ON
SETSCALE 479,799
StrokeWidth 3
DEGREE

tx=SCREENX()/2
ty=SCREENY()/2

COLOR 75,0,0

DrawingBuffer on

color 0,0,0
cls

FOR w=0 TO 360 STEP 6
  COLOR 75,0,0
  x=SIN(w)*180+tx
  y=COS(w)*180+ty
  LINE x,y,SIN(w)*20+x,COS(w)*20+y
  IF (w%30)=0 THEN
    COLOR 0,0,75
    x=SIN(w)*160+tx
    y=COS(w)*160+ty
    LINE x,y,SIN(w)*40+x,COS(w)*40+y
  ENDIF
NEXT w

DrawingBuffer off

ox = 0
oy = 0

DO
  t$=FORMATTIME$(TIME(),"hhmmss")
  s=VAL(MID$(t$,5,2))
  IF so<>s THEN
    so=s

    cls
    COLOR 0,100,0
    m=VAL(MID$(t$,3,2))
    LINE tx,ty,SIN(180-(m*6))*155+tx,COS(180-(m*6))*155+ty
    w=VAL(MID$(t$,1,2))
    LINE tx,ty,SIN(180-(w*30)-(m*0.5))*120+tx,COS(180-(w*30)-(m*0.5))

*120+ty
    COLOR 0,25,0
    LINE tx,ty,SIN(180-(s*6))*155+tx,COS(180-(s*6))*155+ty
    CIRCLE SIN(180-(s*6))*140+tx,COS(180-(s*6))*140+ty,10,1
  ENDIF

  setDrawingBufferOffset ox, oy
  ox += 2
  oy += 2
  render

LOOP
Logged
Pages: [1] 2
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines
Page created in 0.036 seconds with 18 queries.