Skip to content

Instantly share code, notes, and snippets.

View toshok's full-sized avatar

Chris Toshok toshok

  • San Francisco, CA
View GitHub Profile
@toshok
toshok / problem-or-opportunity?.md
Last active March 6, 2016 18:29
the problem with a CESK style machine for javascript

this is the evaluation function for binary expressions (addition only) according to ES2015 spec, expressed in my JS CESK machine.

    eval(fp, store, kont) {
        let lref = this._left.eval(fp, store, kont);
        let lval = es6.GetValue(lref, store);
        let rref = this._right.eval(fp, store, kont);
        let rval = es6.GetValue(rref, store);
        switch (this.operator) {
        case '+': {
@toshok
toshok / stuff.md
Created December 28, 2015 17:14
calling conventions are for losers
static ejsval _ejs_Number_prototype_toString(ejsval env, ejsval _this, uint32_t argc, ejsval* args, ejsval newTarget);

ejsval  
_ejs_number_to_string(ejsval num)
{
    return _ejs_Number_prototype_toString(_ejs_undefined, &num, 0, NULL, _ejs_undefined);
}
@toshok
toshok / gist:d4ca2b2fe3c1867063cc
Created January 29, 2015 16:30
echojs + gitlet.js
$ ejs.exe -o gitlet gitlet.js
running on darwin-x86_64
generating code for darwin-x86_64
PARSE gitlet.js
COMPILE gitlet.js
LINK gitlet
done.
$ mkdir a
$ cd a
$ file ../gitlet
$ sudo add-apt-repository ppa:toshok/echojs
[... some output, hit enter to confirm ...]
$ sudo apt-get update
[... lots of output...]
$ sudo apt-get install echojs
[... potentially lots of output...]
$ echo "console.log('it worked');" > hello.js
$ ejs hello.js
running on linux-x86_64
generating code for linux-x86_64
@toshok
toshok / gist:e8b1278a5cd84a595987
Created January 14, 2015 16:20
annotated node-compat.ejs

Hopefully much of the content of this file will go away and be replaced by something that lives in the actual package file. I'm loathe to create yet another .zip/.jar package, but it might not be the worst thing.

Until then, this file must live in a --module-dir specified on the search path (defaulting to ../lib relative to the compiler executable).

{
    // this version specifies two things: the version of the syntax of this file,
    // as well as the runtime abi in use.  the compiler will (eventually) refuse
    // to load modules which don't match its semver.
    "ejs_version": "0.0.0-alpha1",
@toshok
toshok / gist:e612f19ccbf17450d7aa
Last active December 21, 2016 22:14
GitHub Counter-Notification for CraftBukkit

GitHub Counter-Notification for CraftBukkit

This counter notification is for:

The DMCA takedown request for CraftBukkit was motivated by license terms that do not apply to source code in situ, only to the distribution of resulting binary packages. The multiple claims of problems in the repository have nothing to do with the actual source code, but with resulting binary releases.

Indeed, in the original notice, this line:

@toshok
toshok / gist:4917c4b04efad04cb0c3
Last active August 29, 2015 14:05
ejs module plans

#ejs modules (what I want to see)

##the easier bits

take the following modules:

// for template strings without a tag (i.e. of the form
// `literal ${with}${possibly}${substitutions}`) we simply
// inline the spec'ed behavior of the default handler (zipping
// together the cooked values and substitutions to form the
// result.)
//
// for tagged templates: (i.e. of the form tag`literal`) we
// create a function which lazily generates the const/frozen
// callsite_id, which is a unique object containing both raw
@toshok
toshok / gist:8f197722cacd0740d3ca
Last active August 29, 2015 14:03
let + loops + generators = fun

I'm working on ejs's support for generator functions, and have a few tests that I think exercise more complex interactions with JS syntax. Control flow interactions are the ones we naturally think about, like nested try/catch/finally (ugh, finally), loops, breaks/continue statements with labels, etc.

Lexical scoping is also one of those complex interactions, one that bugs me more than the others.

Here's one of my current tests:

function* foo() {
  for (var i = 0; i < 10; i ++) {
    let x;
 yield x;
@toshok
toshok / gist:b66cf55710fc008185a7
Created June 26, 2014 04:23
generators are coming
13.js ==============
function* gen_test() {
return yield log(yield 5);
}
end block is %BB1
---------------------
%BB_start0
%yieldAndResumeAt(5, %BB3);
%BB3
%tmp_0 = %getResumeVal();