this week I put some more work on teh script system which is a object orieted laguage derive from Java and csharp
I would going with Lua but teh lack of OOP in Lua is a turn off for me. oen fo eth main reason fo rthsi scrip laguan si that it will have buidl in support for emdibng with oteh laguages.
basically It will use the Java native funtion support for that.
It is also an optimizing compiler, I still have long way to go but here is ha oputput of a intemediate laguge code genmerated for a naive quick sort
thsi si a calss example
- Code: Select all
// a very naive qsort for integers
public class qsort
{
// very primitive qsort
public void sort (int[] a, int m, int n)
{
if (n <= m) {
return ;
}
int i = m - 1;
int j = n;
int v = a[n];
int x;
while (1) {
do
i = i + 1;
while (a[i] < v);
do
j = j - 1;
while (a[j] > v);
if (i >= j) {
break;
}
x = a[i];
a[i] = a[j];
a[j] = x;
}
x = a[i];
a[i] = a[n];
a[n] = x;
// sort (a, m, j);
// sort (a, i + 1, n);
}
}
this is the intemediate laguage generated
- Code: Select all
[code]optimized version
function sort
argument a
argument m
argument n
local scope0_i
local scope0_j
local scope0_v
local scope0_x
if (n <= m) goto exit
scope0_i = m - 1
scope0_j = n
t0 = n * 4
scope0_v = a[t0]
label3:
scope0_i = scope0_i + 1
t1 = scope0_i * 4
t2 = a[t1]
if (t2 < scope0_v) goto label3
label7:
scope0_j = scope0_j - 1
t3 = scope0_j * 4
t4 = a[t3]
if (t4 > scope0_v) goto label7
if (scope0_i >= scope0_j) goto label2
t5 = scope0_i * 4
scope0_x = a[t5]
t6 = scope0_j * 4
t7 = a[t6]
a[t5] = t7
a[t6] = scope0_x
goto label3
label2:
t8 = scope0_i * 4
scope0_x = a[t8]
t9 = n * 4
t10 = a[t9]
a[t8] = t10
a[t9] = scope0_x
exit:
ret[/code]
this code is almos as good as what Visual studio prouce ins release build, but it use a lot more registers.
my next step if to use and dynamics Registare allocation, to regide the number or local variables, and this will make a good canditate for Just in time compiler.
I have big plan for this project
I anyone can comment I like to hear soem opinions about this project.
This script languge is a standalone project.