CPCWiki forum

General Category => Programming => Topic started by: zhulien on 22:19, 17 July 19

Title: jscompile
Post by: zhulien on 22:19, 17 July 19

I have made a small update to jscompile, it isn't finished but enough to demo for the first time. 

It could be expanded to include assets (graphics and maps), integration with 8bitology API (for achievements), direct sending to CPC, modules etc.  Modules should be there, with classes allocated on the heap, not static, local variables on the stack to allow recursion and some code optimisations.  With modules the ability to make them public with versioning so coders can include them directly.

http://8bitology.net/poc/jscompile/ (http://8bitology.net/poc/jscompile/)

What are your thoughts on this? Should I finish it? Would anyone want to use it if it could generate CPC code?

To demo it, just type something in from scratch, eg: (yes, it is sensitive to spacing for now)

function Main1()
    var TEST1 = 1;
    var TEST2 = TEST1 * 5;
    var TEST3 = (TEST2 + TEST1) * 2;
    var loopCounter = 10;
    while (loopCounter > 0)
        loopCounter --;

Also, does anyone want to help me finish it? I prefer to make it free for any purpose.
Title: Re: jscompile
Post by: zhulien on 21:46, 14 April 20
I updated the POC of JSCompile... lots of bugs fixed, you can now type in lots of very complex logic and see it compile as you type.  No function calls just yet, but coming...


https://www.youtube.com/watch?v=q8kBgWHT944 (https://www.youtube.com/watch?v=q8kBgWHT944)
Title: Re: jscompile
Post by: m_dr_m on 11:31, 15 April 20
I would use it if it ran on CPC (:
Title: Re: jscompile
Post by: ervin on 11:33, 15 April 20
This is very, very cool!
Title: Re: jscompile
Post by: zhulien on 13:24, 15 April 20
I would use it if it ran on CPC (:

If you saw my other thread about using multiple displays from CPC (via http calls), you might notice the additional screens look like CPC screens too.  This isn't coincidence, but some of the canvas work I have done already I hope to allow a program to be written and tested/debugged in JS, but compiled and also run on a real CPC. 

It would be nice to self-host it on a real CPC and time will tell if that is ever possible.  Possibilities include using revaldinho's CPCLINK card and Raspberry PI directly on CPC, or perhaps an 8BML extension to allow web-terminals?
Title: Re: jscompile
Post by: zhulien on 06:38, 31 May 20
I have updated JSCompile at the above link to handle expressions better and more accurately and with less limitations.

Please read the notes which are as comments.

I think the remaining functionality needed to make it minimally useful is:

- new keyword object allocation
- calling functions with optional parameters
- function receiving parameters
- function return values

Mainly because I am undecided on the memory model yet, re: the other thread of mine.