{"id":13528336,"url":"https://github.com/eatonphil/jsc","last_synced_at":"2025-03-15T12:30:29.218Z","repository":{"id":34966691,"uuid":"135830482","full_name":"eatonphil/jsc","owner":"eatonphil","description":"A JavaScript compiler written in TypeScript targeting C++/V8","archived":false,"fork":false,"pushed_at":"2022-12-08T15:33:14.000Z","size":250,"stargazers_count":198,"open_issues_count":11,"forks_count":10,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-02-27T01:13:46.833Z","etag":null,"topics":["cpp","javascript","javascript-compiler","typescript","typescript-compiler","v8"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eatonphil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-02T15:42:23.000Z","updated_at":"2025-02-22T08:24:41.000Z","dependencies_parsed_at":"2022-08-08T03:01:25.433Z","dependency_job_id":null,"html_url":"https://github.com/eatonphil/jsc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eatonphil%2Fjsc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eatonphil%2Fjsc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eatonphil%2Fjsc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eatonphil%2Fjsc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eatonphil","download_url":"https://codeload.github.com/eatonphil/jsc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243730842,"owners_count":20338724,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","javascript","javascript-compiler","typescript","typescript-compiler","v8"],"created_at":"2024-08-01T06:02:26.283Z","updated_at":"2025-03-15T12:30:28.906Z","avatar_url":"https://github.com/eatonphil.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Javascript compiler targeting C++/V8\n\n### Building\n\nRequires Node.\n\n```bash\n$ yarn\n```\n\n### Example\n\n```bash\n$ yarn tsc\n$ node build/jsc.js tests/tco.js\n$ node bin/index.js\n12586269025\n\n```\n\n### Features\n\n* Functions and function calls\n  * Basic tail-call optimization\n* Var, const, let declarations\n* For, do, while statements\n* Basic primitive operations\n* Basic import support\n* Number, string, boolean and null literals\n* Basic value unboxing\n\n#### Not (yet) supported\n\n* Prototype functions\n* Nested functions\n* Closures\n* And much, much more!\n\n### Code produced\n\nThe following:\n\n```js\nfunction fib(n: number, a: number, b: number) {\n    if (n == 0) {\n        return a;\n    }\n\n    if (n == 1) {\n        return b;\n    }\n\n    return fib(n - 1, b, a + b);\n}\n```\n\nGets compiled to:\n\n```cpp\nvoid tco_fib(const FunctionCallbackInfo\u003cValue\u003e \u0026args) {\n  Isolate *isolate = args.GetIsolate();\n  double tco_n = toNumber(args[0]);\n  double tco_a = toNumber(args[1]);\n  double tco_b = toNumber(args[2]);\n\ntail_recurse_1:\n\n    ;\n\n  bool sym_if_test_58 = (tco_n == 0);\n  if (sym_if_test_58) {\n    args.GetReturnValue().Set(Number::New(isolate, tco_a));\n    return;\n  }\n\n  bool sym_if_test_70 = (tco_n == 1);\n  if (sym_if_test_70) {\n    args.GetReturnValue().Set(Number::New(isolate, tco_b));\n    return;\n  }\n\n  Local\u003cValue\u003e sym_arg_83 = Number::New(isolate, (tco_n - 1));\n  Local\u003cValue\u003e sym_arg_92 = Number::New(isolate, (tco_a + tco_b));\n  tco_n = toNumber(sym_arg_83);\n  tco_a = tco_b;\n  tco_b = toNumber(sym_arg_92);\n  goto tail_recurse_1;\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Featonphil%2Fjsc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Featonphil%2Fjsc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Featonphil%2Fjsc/lists"}