corellaScript : Functions and Objects

With only two days left before the hard dead line and that will the end of my first GSOC . These three months has given me a tremendous insight into the world of open source, scripting languages and off-course compilers.

The good parts

Three months ago, I was a programmer who knew how to programme in javascript and few other languages but nothing about what is going inside the compiler which drives a language but now I know what makes javascript so dynamic and powerful ,I know how code is read, converted into tokens and the formation of Syntax tree.
All thanks to my project : implementing javaScript compiler on Parrot . Though corella is not able to compile itself which means that my project is not fully ready to use. I failed at many points and sometimes took some wrong decisions as well but realizing that mistakes are the part of life and I actually learned a lot from them.

I learned PIR, a totally new language for me, kind of a high level assembly language and I fell in love with it :-), though it was not easy to get PIR from a given syntax tree representation.
One more thing I have gained from my project is understanding the most important but difficult to understand topics in JavaScript like closures and use of "this". which I'll be using in future for sure,
corella is able to produce correct PIR for many js codes,
It is able to do basic stuffs like functions, objects, integers, strings, things, objects and arrays. In these 2 days I'll try to add more features.

The bad ones
unfortunately, corella is not still not able to compile itself at this time. I can't blame that It was difficult project but It was partly due to some of my bad decisions like whe I got panicked when job session started one month earlier and had to sit for certain interviews and prepare for them but didn't got selected, that made me nervous for some time but not anymore , I'm more confident now and focused , Given a chance I'll like to work on Corella after the 22 as well.
I was not able to utilize the starting month. first thing that I was new to compilers so It took some time to understand the algorithms and also the parser's code, grammar of JavaScript.
It was also during that time, that I realized some of my concepts of JavaScript were also not up to the mark, which I'm glad are now quite good

Okay, well that was the whole summery and some good news that
The corella is now having support for functions as well, I'm working on another design for function but till than I've decided that this is not bad as well

function abc(a,b)
	var c = a+b

results in

.HLL "corella"
.include "corella_system.pir"
.sub 'main' :main

.sub 'abc' :outer('main')
.param pmc a
.param pmc b 
$P0 =  a + b
print $P0

corella also has some support for objects,
the pir objects handling uses "jsObject" which are simple PIR "hash" pmcs

var obj = {};

gives the following on compilation

.HLL "corella"
.include "corella_system.pir"
.sub 'main' :main
$P0 =  new 'jsObject'
set_global 'obj', $P0

for more concrete example, let say we have

var stooge = {

results in

.HLL "corella"
.include "corella_system.pir"
.sub 'main' :main
$P0 =  new 'jsObject'
$P1 = new 'jsObject'
$P1["alpha"] = "Jerome"

$P2 = new 'jsObject'
$P2["beta"] = "Howard"

set_global 'stooge', $P0

corella's test suite which is based on nodeunit is also ready and functioning, there were some errors earlier regarding the test suite which are now fixed and it is working perfectly fine right now.

I didn't tried PAST but don't think I'm ready to use that right now, may be during my this semester in which I'm having compiler as main course I'll be able to understand grammars and Syntax tree and will use PAST after that.

for the documentation of project I will talk to Coke today and decide about the final view of documentation. for the API documentation, It is ready for most of the parts, and blog posts are also quite enough for anyone to get started with corella. I've updated the readme of the project regarding the setup of test-suite which requires the installation of nodeunit.