sai-language
Version:
An object-oriented language designed to afford code comprehension and maintenance. Transpiles in-place to Javascript.
138 lines (133 loc) • 3.75 kB
JavaScript
// Javascript source for Via.foo transpiled by SAI
//
;
var $AI=require("sai-library");
var prototype=function(){};
$AI._prototype.apply(prototype);
// Generated code follows
var __context={"name":"Via.foo","loader":"SAI.GetSourceFromPaths","path":"./Via.foo","mtime":"2018-02-03T19:22:48.683Z","fetched":"2018-02-03T19:47:04.148Z"};
var isa = prototype.isa = 'Via';
prototype.isof['Via'] = {
version: '0.0.0-unspecified',
isa: isa,
context: __context,
main: true,
};
prototype.__tobelocked = prototype.__tobelocked.concat(["'Instantiate'", "isa"]);
prototype.__tobefrozen = prototype.__tobefrozen.concat(["isof"]);
var $1g = prototype['Instantiate'];
prototype['Instantiate'] = function(p) {
var _ShowParameters, $5, $4, _rules, _subject, _MySort, _a, $3, $2, $1, _result, _repeat, _Replicate, _fruit, _Concat, _ReverseSort, _r, _l, _Plus, $ = this; {
_Plus = function(p, _r) {
var _l = p; {
return (_l + _r);
}
};
_ReverseSort = function(p, _r) {
var _l = p; {
return $AI.sort(($AI.concat(_l, _r)), function(a, b) {
var aa, bb;
aa = a;
bb = b;
if (aa < bb) return 1;
if (aa > bb) return -1;
return 0;
});
}
};
_Concat = function(p, _r) {
var _l = p; {
return $AI.concat(_l, _r);
}
};
$AI.debug((_Plus).call(this, (1), 2));
$AI.debug(this.isa);
_fruit = ['apple', 'banana', 'citron', 'durian'];
$AI.debug((_ReverseSort).call(this, (_fruit), undefined));
$AI.debug((_Concat).call(this, (_fruit), $AI.sort((['owl', 'asp', 'tarantula']), function(a, b) {
var aa, bb;
aa = a;
bb = b;
if (aa < bb) return -1;
if (aa > bb) return 1;
return 0;
})));
_Replicate = function(p, _repeat) {
var _l = p; {
let _result = [];
var $1 = 0,
$0 = _repeat;
for (; $1 < $0; $1 += 1) {
_result[$1] = _l;
}
return _result.join('');
}
};
_a = 'Hip';
$AI.debug(((_Replicate).call(this, (_a), 2) + 'Hurrah'));
_MySort = function(p, _rules) {
var _subject = p; {
if (($4 = ((_rules.order === 1)))) {
_result = $AI.sort((_subject), function(a, b) {
var aa, bb;
aa = a;
bb = b;
if (aa < bb) return -1;
if (aa > bb) return 1;
return 0;
});
} else {
_result = $AI.sort((_subject), function(a, b) {
var aa, bb;
aa = a;
bb = b;
if (aa < bb) return 1;
if (aa > bb) return -1;
return 0;
});
}
if (undefined !== ($5 = (_rules.count))) {
_result = $AI.slice((_result), undefined, $5);
}
return _result;
}
};
$AI.debug((_MySort).call(this, (_fruit), {
order: 1
}));
$AI.debug((_MySort).call(this, (_fruit), {
order: (0 - (1)),
count: 2
}));
$AI.debug(_MySort(_fruit, {
order: (0 - (1)),
count: 2
}));
$AI.debug(_MySort(_fruit, {
order: (0 - (1)),
count: 2
}));
$AI.debug((_MySort).call(this, (_fruit), {
order: (0 - (1)),
count: 2
}));
_ShowParameters = function(p) {
{
return arguments;
}
};
$AI.debug((_ShowParameters).call(this, (1), 2, 3, 4));
$AI.debug((_ShowParameters).call(this, (1), {
b: 2,
c: 3,
d: 4
}));
}
};
// End of generated code
$AI.finalizePrototype(prototype);
exports=prototype; try { module.exports=prototype; } catch(e) {}
if (prototype.isof[prototype.isa].main) {
var main=prototype.constructor();
}
return prototype;