Last active
January 4, 2016 20:37
-
-
Save PsichiX/65d57dd78095efe3b168 to your computer and use it in GitHub Desktop.
Intuicio++ to JavaScript compilation test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Ass | |
{ | |
Ass(v:int) { _value = v; } | |
~Ass() { _value = 0; } | |
get():int { return _value; } | |
set(v:int):void { _value = v; } | |
property:int | |
{ | |
get { return get(); } | |
set { set(value); } | |
} | |
_value:int = 0; | |
} | |
main():int | |
{ | |
sum(a:int, b:int):int | |
{ | |
return a + b; | |
} | |
inject "console.log('variables:');"; | |
a1:int = 2; | |
a2:int = a1; | |
inject "console.log(a1);"; | |
inject "console.log(a2);"; | |
inject "console.log('arithmetics:');"; | |
a3:int = a1 = -1 + ((-a2 * a1) - 2) / a2; | |
a2 += sum(a1, a2) - a3; | |
inject "console.log(a3);"; | |
inject "console.log(a2);"; | |
inject "console.log('if-statement:');"; | |
if(a1 > a2) | |
a1 = a2; | |
else if(a2 == a3) | |
a2 = sum(a3, a1); | |
else | |
a3 = sum(a2, a1); | |
inject "console.log(a1);"; | |
inject "console.log(a2);"; | |
inject "console.log(a3);"; | |
inject "console.log('for-loop:');"; | |
a1 = 1; | |
for(i:int = 1; i <= 10; ++i) | |
{ | |
if(i < 5) continue; | |
a1 *= i; | |
inject "console.log(a1);"; | |
} | |
inject "console.log('foreach-loop:');"; | |
inject "var data = [1, 2, 3, 4, 5];"; | |
a1 = 1; | |
foreach(v:int in data) | |
{ | |
a1 *= v; | |
inject "console.log(a1);"; | |
} | |
inject "console.log('while-loop:');"; | |
while(true) | |
{ | |
if(a1 < 0) break; | |
a1--; | |
inject "console.log(a1);"; | |
} | |
inject "console.log('classes:');"; | |
// TODO: class instantiation. | |
// ass:Ass = new Ass(1); | |
inject "var ass = new Ass();"; | |
inject "Ass.prototype.___constructor0.call(ass, 1);"; | |
inject "console.log(ass.property);"; | |
} | |
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ node test/ -d | |
>>>IPP>>> | |
class Ass | |
{ | |
Ass(v:int) { _value = v; } | |
~Ass() { _value = 0; } | |
get():int { return _value; } | |
set(v:int):void { _value = v; } | |
property:int | |
{ | |
get { return get(); } | |
set { set(value); } | |
} | |
_value:int = 0; | |
} | |
main():int | |
{ | |
sum(a:int, b:int):int | |
{ | |
return a + b; | |
} | |
inject "console.log('variables:');"; | |
a1:int = 2; | |
a2:int = a1; | |
inject "console.log(a1);"; | |
inject "console.log(a2);"; | |
inject "console.log('arithmetics:');"; | |
a3:int = a1 = -1 + ((-a2 * a1) - 2) / a2; | |
a2 += sum(a1, a2) - a3; | |
inject "console.log(a3);"; | |
inject "console.log(a2);"; | |
inject "console.log('if-statement:');"; | |
if(a1 > a2) | |
a1 = a2; | |
else if(a2 == a3) | |
a2 = sum(a3, a1); | |
else | |
a3 = sum(a2, a1); | |
inject "console.log(a1);"; | |
inject "console.log(a2);"; | |
inject "console.log(a3);"; | |
inject "console.log('for-loop:');"; | |
a1 = 1; | |
for(i:int = 1; i <= 10; ++i) | |
{ | |
if(i < 5) continue; | |
a1 *= i; | |
inject "console.log(a1);"; | |
} | |
inject "console.log('foreach-loop:');"; | |
inject "var data = [1, 2, 3, 4, 5];"; | |
a1 = 1; | |
foreach(v:int in data) | |
{ | |
a1 *= v; | |
inject "console.log(a1);"; | |
} | |
inject "console.log('while-loop:');"; | |
while(true) | |
{ | |
if(a1 < 0) break; | |
a1--; | |
inject "console.log(a1);"; | |
} | |
inject "console.log('classes:');"; | |
// TODO: class instantiation. | |
// ass:Ass = new Ass(1); | |
inject "var ass = new Ass();"; | |
inject "Ass.prototype.___constructor0.call(ass, 1);"; | |
inject "console.log(ass.property);"; | |
} | |
main(); | |
<<<IPP<<< | |
>>>JS>>> | |
(function(){ | |
function __TYPE_VOID(){} | |
__TYPE_VOID.prototype = Object.create(null); | |
var VOID = new __TYPE_VOID(); | |
var __RETURNED = null; | |
var __COSTANT_INT_0 = 0; | |
var __COSTANT_INT_2 = 1; | |
var __COSTANT_INT_1 = 2; | |
var __COSTANT_INT_4 = 5; | |
var __COSTANT_INT_3 = 10; | |
if((function(){ | |
function Ass(){} | |
Ass.prototype = Object.create(null); | |
Ass.prototype.___constructor0 = function(v){ | |
var get = this.get.bind(this); | |
var set = this.set.bind(this); | |
var _value = this._value; | |
_value = ((v)); | |
this._value = _value; | |
}; | |
Ass.prototype.___destructor = function(){ | |
var get = this.get.bind(this); | |
var set = this.set.bind(this); | |
var _value = this._value; | |
_value = ((__COSTANT_INT_0)); | |
this._value = _value; | |
}; | |
Ass.prototype.get = function(){ | |
var get = this.get.bind(this); | |
var set = this.set.bind(this); | |
var _value = this._value; | |
{__RETURNED = ((_value)); return __RETURNED;} | |
this._value = _value; | |
}; | |
Ass.prototype.set = function(v){ | |
var get = this.get.bind(this); | |
var set = this.set.bind(this); | |
var _value = this._value; | |
_value = ((v)); | |
this._value = _value; | |
}; | |
Ass.prototype._value = null; | |
Object.defineProperty(Ass.prototype, "property", { | |
get: function(){ | |
var get = this.get.bind(this); | |
var set = this.set.bind(this); | |
var _value = this._value; | |
{__RETURNED = ((get())); return __RETURNED;} | |
this._value = _value; | |
}, | |
set: function(value){ | |
var get = this.get.bind(this); | |
var set = this.set.bind(this); | |
var _value = this._value; | |
set(((value))); | |
this._value = _value; | |
} | |
}); | |
function main(){ | |
function sum(a, b){ | |
{__RETURNED = ((a) + (b)); return __RETURNED;} | |
} | |
var a1; | |
var a2; | |
var a3; | |
console.log('variables:'); | |
a1 = ((__COSTANT_INT_1)); | |
a2 = ((a1)); | |
console.log(a1); | |
console.log(a2); | |
console.log('arithmetics:'); | |
a3 = a1 = (( - __COSTANT_INT_2) + ((((( - a2) * (a1))) - (__COSTANT_INT_1))) / (a2)); | |
a2 = ((sum(((a1)), ((a2)))) - (a3)); | |
console.log(a3); | |
console.log(a2); | |
console.log('if-statement:'); | |
if(((((a1) > (a2))))){ | |
a1 = ((a2)); | |
}else if(((((a2) == (a3))))){ | |
a2 = ((sum(((a3)), ((a1))))); | |
}else{ | |
a3 = ((sum(((a2)), ((a1))))); | |
} | |
console.log(a1); | |
console.log(a2); | |
console.log(a3); | |
console.log('for-loop:'); | |
a1 = ((__COSTANT_INT_2)); | |
(function(){ | |
var i; | |
i = ((__COSTANT_INT_2)); | |
; | |
for(;((i) <= (__COSTANT_INT_3));(( ++ i))){ | |
if(((((i) < (__COSTANT_INT_4))))){ | |
continue; | |
} | |
a1 = ((i)); | |
console.log(a1); | |
} | |
})(); | |
console.log('foreach-loop:'); | |
var data = [1, 2, 3, 4, 5]; | |
a1 = ((__COSTANT_INT_2)); | |
(function(){ | |
var v; | |
var __FOREACH_CONTAINER = ((data)); | |
for(var __FOREACH_ITERATOR = 0; __FOREACH_ITERATOR < __FOREACH_CONTAINER.length; ++__FOREACH_ITERATOR){ | |
v = __FOREACH_CONTAINER[__FOREACH_ITERATOR]; | |
a1 = ((v)); | |
console.log(a1); | |
} | |
})(); | |
console.log('while-loop:'); | |
while(((((true))))){ | |
if(((((a1) < (__COSTANT_INT_0))))){ | |
break; | |
} | |
((a1 -- )); | |
console.log(a1); | |
} | |
console.log('classes:'); | |
var ass = new Ass(); | |
Ass.prototype.___constructor0.call(ass, 1); | |
console.log(ass.property); | |
} | |
main(); | |
})() !== undefined)return __RETURNED; | |
})(); | |
<<<JS<<< | |
>>>EVALUATION>>> | |
variables: | |
2 | |
2 | |
arithmetics: | |
-4 | |
2 | |
if-statement: | |
-4 | |
2 | |
-2 | |
for-loop: | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
foreach-loop: | |
1 | |
2 | |
3 | |
4 | |
5 | |
while-loop: | |
4 | |
3 | |
2 | |
1 | |
0 | |
-1 | |
classes: | |
1 | |
<<<EVALUATION<<< | |
> DONE! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment