I proudly present the first video preview of the new GLBasic to HTML5 compiler, GLBScript! The compiler is fully self hosting
Further I want to say, that EVERY GLBasic syntax element is now fully working. PROTOTYPEs, "FUNCTION in TYPEs",
CALLBACK or even GOTO is doing its job wonderfull!History!
2 years ago, I wrote the first post about GLBScript (formerly GLScriptBasic) in the german forumhttp://www.glbasic.com/forum/index.php?topic=4524.0
. Originally it was just considered as a scripting language
for GLBasic with the exact syntax of GLBasic. Development was rapid and with no minor problems. UNTIL there
was a bug - I call it "THE BUG". This little bastard stopped the whole development. I spent hours or hours
hunting the bug... But after two weeks I gave up and suspended development of GLScriptBasic...
One year passed and finally I got myself together and started working on "GLBScript". This time there
was no big surprise... I knew what went wrong and how to avoid this again. So I programmed until september.
I had a lot of syntax elements of GLBasic running in GLBScript and it was quite usable. ALIAS and BYREF
were implemented and some extra goodies! But then school started...
Development slowed down a lot. I had only 5 hours a week time for GLBScript. But i didn't give up and continued
steadily. I tried to make the compiler self hosting (compiles its own source code), which was a hard taks to achieve.
Finally in the end of march I've implemented enough functions and fixed bugs to get this working. I was really happy about this,
because this meant the compiler is stable, fast and the features are also working together. Then easter holidays began and I
was very procuctive... I've implemented the last missing syntax element - goto and I have also reprogrammed the whole filesystem
API. After easter holidays I just started to port some of the included samples of GLBasic... during that I fixed a lot of bugs.GOTO!
more machine code like structure. Of course as soon as you use a single GOTO in a scope the whole scope gets
transformed into this, but I think that's quite reasonable.Filesystem!
The next monster I had to kill was the low level filesystem API of GLBasic. The main problem is, in HTML5
there is no filesystem alike API available (except for Google Chrome, but this was no choice, because I want
GLBScript running in every browser!). There is only a Key - Value storage available in every browser. So I
had to implement a beast I call "Virtual File System". It basically wraps the whole Filesystem into an abstract
persistent file storage across every browser. Even old browsers with no "Localstorage API" this works fine (just
So all Filesystem functions are available (WRITE... READ... INI... and many more)
I also spent some time on improving the 2D engine of GLBScript. It is fully capable of converting the "Blocks", "Arkanoid", "FourInARow",
"Pong" and "JumpFrog" samples to HTML5 with literally no changes in the source code (except the GLB_ON_LOOP modification)Self hosting!
As already mentioned, the compiler is fully self hosting. That means it is capable of compiling itself and produce executable
So what's the goal of this?
- It's a good self test whether the compiler compiles accurate code. Compiling a compiler is not a trivial task.
- EVAL() would be a possible function, and maybe I will include it.
- Online development enviroment is possible. Developing your GLBasic Apps on the web. I already started a simple online IDE!
but I am quite happy about this.Improved Debugging!
If an error occurs you see the current line of execution, a detailed stacktrace and of course the error message. The whole API does a lot more
saftey checks. You are able to get the current stacktrace in GLBasic with the new command "STACKTRACE$".
Google Closure is also used. In release mode Closure optimizes and minimizes the output code and in debug mode it cleans the code and indents. Google Closure is
a really nice tool and it's quite lightweight!Inheritance!
Yeah that's right! GLBScript supports inheritance and ABSTRACT methods. That means you can program in basic OOP. But I want to keep it simple and not too overloaded.
Implementing this feature was not that difficult. But of course I had to reimplement FUNCTION in types to get "late binding" working.Automatic media management!
As you know, audio is a pain when trying to be cross platform... Of course in HTML5 it's the same problem. Different browsers support different sound formats. So I wrote an automatic converter for this issue. It takes your audio file and converts it automatically into .ogg and .mp3 files. You have to do nothing as a programmer. GLBScript takes care and converts - a pretty handy feature I think. For converting to mp3 I use LAME and for .ogg SOX. Videos!
Programming a little game:Part1Part2Deep look into the compiler itself!Demos!
Debug mode is on in every demo, so it's probably a little slow. But at the moment it just matters THAT it works...
My programming philsophy is "First make it run, then make it run fast". Self hosting compiler
(wait a few seconds until it has compiled itself. After waiting you see the code of GLBScript in
Fixed: FOR had strange behaviour in recursionDownload!
Fixed: "FOR i = 0 TO 0" executes correctly
Fixed: "4 - 5 + 6" or "TRUE OR FALSE AND FALSE" do not throw a syntax error
Fixed: i% = 4; STDOUT i% works (the %)
Fixed: Line numbering is now (almost) correct
Fixed: (multidimensional) arrays are more robust
Fixed: floats like ".5" implemented
Fixed: Some problems with references fixed
Fixed: Uninitialized arrays have now correct default values
Fixed: TRY - CATCH works in GOTO scope properly
Fixed: "GETTIMERALL" returns milliseconds since page loaded instead of unix timestamp
Fixed: "NOT" returned a boolean instead of an integer
Fixed: GETFILELIST: uses the filter$ parameter
Fixed: Hex values fixed
Fixed: RGB returned incorrect number
Fixed: 2D uses context.save() and context.restore()
Fixed: Unexpected "gotocounter exception" fixed.
Fixed: Compiler error messages display correct line number, path and character where the error happened
Fixed: KEY uses GLB Scancodes
Fixed: Some safety checks in the file API
Fixed: Codefolding is supported properly
Fixed: Array position screwed up in 3 or 4 dimensional arrays...
Fixed: Wrong dereferencing when calling a NATIVE function
Fixed: CONSTANT with multiple identifiers (CONSTANT IS_A = 0, IS_B = 1, IS_C = 2)
Fixed: Width and Height from the .gbap file
Fixed: Sound in Opera and IE
Fixed: RGB returned sometimes wrong value
Fixed: SETTRANSPARENCY: Implementation is a weird hack, please use only if there are no other possibilities
Fixed: STRETCHSPRITE stretches the sprite properly
Fixed: Wrong behaviour when performing "IF" with floats
Fixed: STRETCHSPRITE with width = 0 or height = 0 does not crash Firefox anymore
Fixed: Implicit defintion of arrays if there is a 
Fixed: No infinite loop while trying to load a non existing image or sound
Fixed: Array access optimized.
Fixed: Preprocessor screwed around with ?ELSE...
Fixed: \f in strings are not compiled into \n anymore
Fixed: CAST2INT() cuts decimals correctly
Fixed: Numbers beginning with 0 does not throw a syntax error anymore (040 for example)
Fixed: STARTDATA data:\n DATA functCall()\n ENDDATA <- Works now with function calls
Fixed: RND should work as expected
Fixed: CALLBYNAME("10") throws no syntax error when executed...
Fixed: Touch support for Android
Fixed: No context menu on right click onto the canvas
Fixed: Callbacks and function in types are functioning together
Fixed: MOUSEAXIS with mouse wheel support!
Added: FOREACH with multidimensional arrays
Added: ?BLACKLIST "file" - For Blacklisting Files/Folders (are not included in the final .html file), "?BLACKLIST ALL" blacklists all files => no file is included!
Added: "_" symbol for ignoring the newline token
Added: BOUNDS(array, dimension)
Added: Fully functional GOTO - still needs some debugging
Added: "GOTO on demand" overhead reduction: goto overhead (a big switch - case monster) is only inserted when it's really necessary
Added: "Virtual File System" Engine: Flexible managing of your (persistent and non persistent) data in a nice filesystem like enviroment.
Added: STDERR (calls STDOUT with "Error: " prefix)
Added: SHELLEND (calls SHELLCMD and END)
Added: DECRYPT$/ENCRYPT$: does not use blowfish...
Added: PUTENV (just a key - value storage)
Added: FORCEFEEDBACK (basic support, api is not very flexible...)
Added: GETCOMMANDLINE (returns the url parameter)
Added: PUSHLOOP loop$ (new command: pushes a new Renderloop onto the stack)
Added: POPLOOP (new command: pops the last renderloop from the stack)
Added: GETCURRENTLOOP$ (new command: returns the current name of the renderloop)
Added: RETURNTOLOOP: loop$ (new command: "walks" through the loopstack until it gets to the given loopname)
Added: ANYKEY: (new command: instead of KEYWAIT, returns true if a key is pressed if not it returns false)
Added: Useful debug information (if a error occurs) in debugmode: Stacktrace (prints the complete function call history and its parameters) and the current line of execution
Added: ?OPTIMIZE NONE | SIMPLE | AGGRESSIVE - How much should be optimized? None does nothing, Simple does very little optimzation and aggressive does nearly everything (problem with aggressive is, that it runs sometimes slower than the other techniques)
Added: Implicit variable declaration (Use variables without their declaration)
Added: STACKTRACE$ (new command: returns the current stacktrace in debug mode)
Added: Automatic audio converting to the common HTML5 audio formats (.mp3 and .ogg) - A very handy feature!
Added: Improved lexing speed: Uses now Hashmaps (In future I will rewrite the "identifier search engine" to use hashmaps, at the moment the native GLB arrays are used for this...)
Added: "Compile to HTML5" macro for GLBasic IDE - compile to HTML5 easily from the IDE.
Added: GOTO checks are now performed: You are only able to jump to defined labels.
Added: IIF(condition%, onTrue%, onFalse%)
Added: GLB_ON_LOADING: As long as GLBScript is loading data, this sub is callen... to check whether a sprite is loaded or not, use GETSPRITESIZE!
Added: GETMOUSECOUNT (mult touch support, need some bugfixing on Android/iOS...)
Added: Experimental inheritance feature, FUNCTION in types reprogrammed...
Added: Experimental ABSTRACT feature
* This function is just a dummy, because it is not possible to implement this feature and/or it's not worth it.
Not yet available... but soon you are able to test it on your own!Future goals!
- Optimize compiler speed (At the moment the compiler is really slow...)
- Implement missing functions!
- Bug fixing!
- Fix all TODOs in code
- Compile every 2D game and execute it properly (after the GLB_ON_LOOP change)
- Get 3D commands working and implement a WebGL driver (that will take a lot of work...)