%COMPILE(eval(%expr)
, %env)
==>
do {
let $callee = eval;
if ($callee === $runtime.crockEval) {
let $src = $runtime.crockpile(%COMPILE(%expr, %env), %env);
let eval = $runtime.es7Eval;
// This code currently compiles with Traceur. It doesn't compile with esnext, | |
// which doesn't support generator comprehensions. | |
// Sudoku board: | |
// | |
// A1 A2 A3 | A4 A5 A6 | A7 A8 A9 | |
// B1 B2 B3 | B4 B5 B6 | B7 B8 B9 | |
// C1 C2 C3 | C4 C5 C6 | C7 C8 C9 | |
// ---------+----------+--------- | |
// D1 D2 D3 | D4 D5 D6 | D7 D8 D9 |
import { Promise } from 'rsvp'; | |
import asap from 'rsvp/asap'; | |
var config = { | |
Promise: Promise, | |
asap: asap | |
}; | |
function Task(thunk, self) { | |
this._result = undefined; |
import spawn from 'task'; | |
import asap from 'rsvp/asap'; | |
import { Promise } from 'rsvp'; | |
function sleep(n) { | |
return new Promise(function(resolve, reject) { | |
setTimeout(function() { | |
resolve(); | |
}, n); | |
}); |
%COMPILE(eval(%expr)
, %env)
==>
do {
let $callee = eval;
if ($callee === $runtime.crockEval) {
let $src = $runtime.crockpile(%COMPILE(%expr, %env), %env);
let eval = $runtime.es7Eval;
// arguments.length === 0 | |
dict = new Dict(); | |
// arguments.length > 0, typeof arguments[0][@@iterator]] !== 'undefined' | |
dict = new Dict([["a", 1], ["b", 2], ["c", 3]]); | |
// arguments.length > 0, typeof arguments[0][@@iterator] === 'undefined' | |
dict = new Dict({ "a": 1, "b": 2, "c": 3 }) | |
// arguments.length === 1, typeof arguments[0][@@iterator] === 'undefined' |
if (typeof performance.test !== 'function') { | |
var now = performance.now; | |
performance.test = function test(thunk) { | |
var start = now(); | |
// no args, no thunk.call(thisArg) flexibility, no catch, | |
// to minimize overhead that could add noise to the result | |
var result = thunk(); | |
var end = now(); | |
return { | |
result: result, |
class Stack extends Array { | |
constructor() { | |
new { | |
return [] | |
} | |
} | |
top() { | |
if (!this.length) | |
throw new Error("empty") | |
return this[this.length - 1] |
struct Foo<&r> { | |
data: MMappedFile<&r>, | |
hash: HashMap<&r str, &r str> | |
} | |
fn new(filename: &str) -> Foo<&r> { | |
let mut foo = Foo { | |
data: map_file(filename), | |
hash: HashMap::new() | |
}; |
import * as fs from "fs"; | |
let exports; | |
// reflective API takes environment descriptors and uses revealing constructor pattern | |
// to expose mutators to the creator of the module instance object | |
var mod = new Reflect.Module({ | |
// initialized mutable (includes "uninitialized" var) | |
x: { value: undefined }, | |
y: { value: 42 }, |
import * as a from "a"; | |
"foo" in a // false. a well-behaved in-check should indicate that a get should succeed | |
a.foo // dynamic error |