├── .github └── workflows │ ├── codeql-analysis.yml │ └── node.js.yml ├── .gitignore ├── LICENSE ├── README.md ├── package-lock.json ├── package.json ├── scheme.code-workspace ├── scheme.wasm.ui ├── about.html ├── assets │ ├── icons.plain.svg │ └── icons.svg ├── favicon │ ├── scheme.wasm.logo.16.png │ ├── scheme.wasm.logo.32.png │ ├── scheme.wasm.logo.96.png │ └── scheme.wasm.logo.svg ├── fonts │ ├── roboto-v29-latin-500.woff │ ├── roboto-v29-latin-500.woff2 │ ├── roboto-v29-latin-700.woff │ ├── roboto-v29-latin-700.woff2 │ ├── roboto-v29-latin-regular.woff │ ├── roboto-v29-latin-regular.woff2 │ ├── source-code-pro-v18-latin-regular.woff │ └── source-code-pro-v18-latin-regular.woff2 ├── index.html ├── package.json ├── src │ ├── Jiffies.ts │ ├── RuntimeWorker.ts │ ├── SchemeRuntime.tsx │ ├── SchemeType.tsx │ ├── components │ │ ├── About.tsx │ │ ├── Burger.tsx │ │ ├── Debugger.tsx │ │ ├── Editor.tsx │ │ ├── EmergencyStop.tsx │ │ ├── Flyout.tsx │ │ ├── FocusContext.tsx │ │ ├── HeapInspector.tsx │ │ ├── IconButton.tsx │ │ ├── RuntimeStatus.tsx │ │ ├── SchemeRuntimeProvider.tsx │ │ ├── Settings.tsx │ │ ├── SettingsMenu.tsx │ │ ├── Terminal.tsx │ │ ├── TerminalData.tsx │ │ ├── TerminalEditor.tsx │ │ ├── TerminalInput.tsx │ │ ├── ThemeProvider.tsx │ │ └── ToggleSwitch.tsx │ ├── global.d.ts │ ├── icons │ │ ├── IconProps.tsx │ │ ├── copy.tsx │ │ ├── cut.tsx │ │ ├── icons.ts │ │ ├── logo.tsx │ │ ├── open.tsx │ │ ├── paste.tsx │ │ ├── redo.tsx │ │ ├── save.tsx │ │ └── undo.tsx │ ├── index.tsx │ ├── monaco │ │ ├── scheme.ts │ │ ├── solarized-contrast.ts │ │ ├── solarized.ts │ │ └── theme.ts │ ├── styles │ │ ├── animations.module.css │ │ └── page.module.css │ ├── util.ts │ └── worker │ │ ├── messages.ts │ │ └── worker.ts ├── tsconfig.json └── webpack.config.js └── scheme.wasm ├── buildwat.json ├── package.json ├── src ├── builtins.wat ├── conditionals.wat ├── continuations.wat ├── define.wat ├── display.wat ├── environment.wat ├── exceptions.wat ├── gc.wat ├── hashtable.wat ├── heap.wat ├── include.wat ├── index.ts ├── lambda.wat ├── let.wat ├── library │ ├── boolean.wat │ ├── bytevector.wat │ ├── char.wat │ ├── complex.wat │ ├── equiv.wat │ ├── grisu.wat │ ├── mp.wat │ ├── numerics-core.wat │ ├── numerics.wat │ ├── pair.wat │ ├── procedures.wat │ ├── process.wat │ ├── real.wat │ ├── string.wat │ ├── symbol.wat │ ├── time.wat │ ├── trig.wat │ └── vector.wat ├── macros.wat ├── malloc.wat ├── port.wat ├── print.wat ├── quote.wat ├── reader.wat ├── record.wat ├── runtime.wat ├── scheme │ ├── guard.scm │ ├── lazy.scm │ ├── numerics.scm │ ├── pair.scm │ ├── port.scm │ ├── prelude.scm │ ├── procedures.scm │ └── test │ │ ├── boolean.spec.scm │ │ ├── bytevector.spec.scm │ │ ├── case-lambda.spec.scm │ │ ├── char.spec.scm │ │ ├── complex.spec.scm │ │ ├── conditionals.spec.scm │ │ ├── control.spec.scm │ │ ├── cxr.spec.scm │ │ ├── equivalence.spec.scm │ │ ├── exceptions.spec.scm │ │ ├── include-ci.spec.scm │ │ ├── include-ci.test.scm │ │ ├── lazy.spec.scm │ │ ├── number.spec.scm │ │ ├── pair.spec.scm │ │ ├── port.spec.scm │ │ ├── process.spec.scm │ │ ├── sequence.spec.scm │ │ ├── string.spec.scm │ │ ├── symbol.spec.scm │ │ ├── test.scm │ │ ├── time.spec.scm │ │ ├── trig.spec.scm │ │ └── vector.spec.scm ├── scripts │ ├── buildwat.ts │ ├── fluent.ts │ ├── parsedwat.ts │ ├── tokens.ts │ ├── unicodedata.ts │ ├── validatewat.ts │ └── watmacro.ts ├── start.wat ├── string.wat ├── syntax.wat └── xxh3.wat ├── tests ├── buildwat.json ├── common.ts ├── environment.spec.ts ├── gc.spec.ts ├── hashtable.spec.ts ├── heap.spec.ts ├── malloc.spec.ts ├── mp.spec.ts ├── print.spec.ts ├── reader.spec.ts ├── runtime.spec.ts ├── scheme.spec.ts ├── string.spec.ts └── xxh3.spec.ts └── tsconfig.json /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ main ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ main ] 20 | schedule: 21 | - cron: '17 13 * * 2' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'javascript' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Learn more about CodeQL language support at https://git.io/codeql-language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v2 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v1 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 52 | 53 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 54 | # If this step fails, then you should remove it and run the build manually (see below) 55 | - name: Autobuild 56 | uses: github/codeql-action/autobuild@v1 57 | 58 | # ℹ️ Command-line programs to run using the OS shell. 59 | # 📚 https://git.io/JvXDl 60 | 61 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 62 | # and modify them (or add more) to build your code if your project 63 | # uses a compiled language 64 | 65 | #- run: | 66 | # make bootstrap 67 | # make release 68 | 69 | - name: Perform CodeQL Analysis 70 | uses: github/codeql-action/analyze@v1 71 | -------------------------------------------------------------------------------- /.github/workflows/node.js.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: Node.js CI 5 | 6 | on: 7 | push: 8 | branches: [ main ] 9 | pull_request: 10 | branches: [ main ] 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | matrix: 19 | # Only works on Node 16.x 20 | node-version: [ 16.x ] 21 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 22 | 23 | steps: 24 | - uses: actions/checkout@v2 25 | - name: Fetch tags 26 | run: git fetch --unshallow --tags 27 | - name: Use Node.js ${{ matrix.node-version }} 28 | uses: actions/setup-node@v2 29 | with: 30 | node-version: ${{ matrix.node-version }} 31 | cache: 'npm' 32 | - run: npm ci 33 | - run: npm run build-prod --if-present 34 | - run: npm run build-dev --if-present 35 | - run: npm test 36 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | *.zip 4 | 5 | node_modules/ 6 | bundle/ 7 | dist/ 8 | .VsCodeCounter/ 9 | codeql/ 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Paul C. Roberts 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | scheme.wasm logo 3 |

4 | 5 | [![Node.js CI](https://github.com/pollrobots/scheme/actions/workflows/node.js.yml/badge.svg)](https://github.com/PollRobots/scheme/actions/workflows/node.js.yml) 6 | [![CodeQL](https://github.com/pollrobots/scheme/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/PollRobots/scheme/actions/workflows/codeql-analysis.yml) 7 | [![FOSSA Status](https://app.fossa.com/api/projects/custom%2B29853%2Fgithub.com%2FPollRobots%2Fscheme.svg?type=shield)](https://app.fossa.com/projects/custom%2B29853%2Fgithub.com%2FPollRobots%2Fscheme?ref=badge_shield) 8 | 9 | [![GitHub stars](https://img.shields.io/github/stars/pollrobots/scheme.svg?style=social&label=Star)](https://github.com/pollrobots/scheme/stargazers) 10 | 11 | # scheme.wasm 12 | 13 | An R7RS Scheme implemented in WebAssembly 14 | 15 | A partial implementation of [r7rs scheme](https://small.r7rs.org/), written 16 | entirely in WebAssembly using the WebAssembly Text format. The only external 17 | imports are for IO (`read`, `write`, and `readFile`), unicode (I have an 18 | import that reads information about 256 code-point blocks to enable case 19 | operations etc.), and process control (`exit`). 20 | 21 | You can try it out at [pollrobots.com/scheme/](https://pollrobots.com/scheme/) 22 | 23 | ## How Complete Is It? 24 | 25 | The aim is to write a spec complete version of `r7rs`, although I may skip 26 | some of the optional features. 27 | 28 | ### What is done so far 29 | 30 | - [x] Numerics 31 | - [x] Integers (arbitrary precision) 32 | - [x] Real numbers (double precision) 33 | - [x] Rationals 34 | - [x] Complex Numbers 35 | - [x] Booleans 36 | - [x] Strings 37 | - [x] Characters 38 | - [x] Pairs and Lists 39 | - [x] Vectors 40 | - [x] Bytevectors 41 | - [x] Values 42 | - [x] Records 43 | - [x] Tail call optimization — internally `eval` uses a continuation passing 44 | style, so TCO comes for free. 45 | - [x] `call/cc` and exceptions 46 | - [x] Macros 47 | - [x] `define-syntax`, `syntax-rules`, `syntax-error` 48 | - [x] Hygienic over `let`, `let*`, `letrec`, `letrec*`, and `lambda` 49 | - [ ] `let-syntax`, `letrec-syntax` 50 | - [ ] Modules 51 | - [ ] Ports 52 | - [ ] `dynamic-wind` 53 | - [ ] Everything else 54 | 55 | ## Credits 56 | 57 | Where practical everything has been implemented from scratch, but there 58 | are places where it either wasn't practical, or where I tried and failed 59 | to implement them myself, so credit is due to: 60 | 61 | - **xxHash**: 62 | It's probably overkill, but the hashing algorithm used for hashtables, 63 | which are in turn used for environments and interning symbols, is xxHash 64 | translated from the C++ implementation at 65 | [github.com/Cyan4973/xxHash](https://github.com/Cyan4973/xxHash) 66 | - **string->real**: 67 | Strings are converted to real numbers using _Algorithm M_ from 68 | "How to Read Floating Point Numbers Accurately", 69 | [William D Clinger](https://www.khoury.northeastern.edu/people/william-d-clinger/) 1990. Which is conveniently expressed in scheme in the original 70 | [paper](https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.45.4152&rep=rep1&type=pdf) 71 | - **real->string**: 72 | Real numbers are converted to strings using _Grisu 2_ by 73 | [Florian Loitsch](https://florian.loitsch.com/home). 74 | This was translated from C++ found at [github.com/romange/Grisu](https://github.com/romange/Grisu) 75 | 76 | Additionally inspiration came from a couple of places 77 | 78 | - **Lispy**: [Peter Norvig's](https://norvig.com) article 79 | [(How to Write a (Lisp) Interpreter (in Python))](https://norvig.com/lispy.html) 80 | was a critical source of inspiration. 81 | - **EPLAiP**: Nearly a decade ago a friend gave 82 | me a copy of 83 | [Exploring Programming Language Architecture in Perl](https://billhails.net/EPLAiP.pdf) 84 | by [Bill Hails](https://billhails.net). Definitely worth reading regardless of 85 | your language of choice (I haven't written PERL this millenium). 86 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "scheme", 3 | "version": "0.0.1", 4 | "workspaces": [ 5 | "scheme.wasm", 6 | "scheme.wasm.ui" 7 | ], 8 | "scripts": { 9 | "build-prod": "npm run build -w scheme.wasm && npm run build-prod -w scheme.wasm.ui", 10 | "build-dev": "npm run build -w scheme.wasm && npm run build-dev -w scheme.wasm.ui", 11 | "start": "npm run build -w scheme.wasm && npm run start -w scheme.wasm.ui", 12 | "test": "npm run test -w scheme.wasm", 13 | "clean": "npm run clean -w scheme.wasm && npm run clean -w scheme.wasm.ui" 14 | }, 15 | "author": "Paul C Roberts ", 16 | "homepage": "https://github.com/PollRobots/scheme#readme", 17 | "license": "MIT", 18 | "devDependencies": { 19 | "rimraf": "^3.0.2" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /scheme.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": ".", 5 | } 6 | ], 7 | "settings": { 8 | "editor.formatOnSave": true, 9 | "editor.tabSize": 2 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /scheme.wasm.ui/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | About scheme.wasm 6 | 41 | 42 | 43 | 44 |

About scheme.wasm

45 |

46 | scheme.wasm is a partial implementation of 47 | r7rs scheme, 48 | written entirely in WebAssembly using the WebAssembly Text 49 | format. The only external imports are for IO (read, 50 | write, and readFile), unicode (I have an import that reads 51 | information about 256 code-point blocks, to enable case operations etc.), 52 | and process control (exit) 53 |

54 |

Where can I find the code

55 |

The code is hosted at github.com/pollrobots/scheme.

56 |

How Complete Is It?

57 |

The aim is to write a spec complete version of r7rs, although 58 | I may skip some of the optional features

59 |

What is done so far

60 | 91 |

What is missing at the moment

92 | 102 |

Credits

103 |

104 | Where practical everything has been implemented from scratch, but there 105 | are places where it either wasn't practical, or where I tried and failed 106 | to implement them myself, so credit is due to: 107 |

108 |
109 |
xxHash
110 |
It's probably overkill, but the hashing algorithm used for hashtables, 111 | which are in turn used for environments and interning symbols, is xxHash 112 | translated from the C++ implementation at 113 | github.com/Cyan4973/xxHash 114 | 115 |
string->real
116 |
Strings are converted to real numbers using Algorithm M from 117 | "How to Read Floating Point Numbers Accurately", 118 | William D Clinger, 119 | 1990. Which is conveniently expressed in scheme in the original 120 | paper.
121 | 122 |
real->string
123 |
Real numbers are converted to strings using Grisu 2 by 124 | Florian Loitsch. 125 | This was translated from C++ found at 126 | github.com/romange/Grisu 127 |
128 |
129 | 130 |

131 | Additionally inspiration came from a couple of places 132 |

133 |
134 |
Lispy
135 |
Peter Norvig's article 136 | 137 | (How to Write a (Lisp) Interpreter (in Python)) 138 | was a critical source of inspiration. 139 |
140 |
EPLAiP
141 |
Nearly a decade ago a friend gave me a 142 | copy of 143 | Exploring Programming Language Architecture in Perl by 144 | Bill Hails. 145 | Definitely worth reading regardless of your language of choice (I haven't written PERL this millenium). 146 |
147 |
148 | 149 | 150 | -------------------------------------------------------------------------------- /scheme.wasm.ui/favicon/scheme.wasm.logo.16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PollRobots/scheme/1ad3ba04ef2674b0fa1f7ce60f443c10c5b23929/scheme.wasm.ui/favicon/scheme.wasm.logo.16.png -------------------------------------------------------------------------------- /scheme.wasm.ui/favicon/scheme.wasm.logo.32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PollRobots/scheme/1ad3ba04ef2674b0fa1f7ce60f443c10c5b23929/scheme.wasm.ui/favicon/scheme.wasm.logo.32.png -------------------------------------------------------------------------------- /scheme.wasm.ui/favicon/scheme.wasm.logo.96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PollRobots/scheme/1ad3ba04ef2674b0fa1f7ce60f443c10c5b23929/scheme.wasm.ui/favicon/scheme.wasm.logo.96.png -------------------------------------------------------------------------------- /scheme.wasm.ui/fonts/roboto-v29-latin-500.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PollRobots/scheme/1ad3ba04ef2674b0fa1f7ce60f443c10c5b23929/scheme.wasm.ui/fonts/roboto-v29-latin-500.woff -------------------------------------------------------------------------------- /scheme.wasm.ui/fonts/roboto-v29-latin-500.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PollRobots/scheme/1ad3ba04ef2674b0fa1f7ce60f443c10c5b23929/scheme.wasm.ui/fonts/roboto-v29-latin-500.woff2 -------------------------------------------------------------------------------- /scheme.wasm.ui/fonts/roboto-v29-latin-700.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PollRobots/scheme/1ad3ba04ef2674b0fa1f7ce60f443c10c5b23929/scheme.wasm.ui/fonts/roboto-v29-latin-700.woff -------------------------------------------------------------------------------- /scheme.wasm.ui/fonts/roboto-v29-latin-700.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PollRobots/scheme/1ad3ba04ef2674b0fa1f7ce60f443c10c5b23929/scheme.wasm.ui/fonts/roboto-v29-latin-700.woff2 -------------------------------------------------------------------------------- /scheme.wasm.ui/fonts/roboto-v29-latin-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PollRobots/scheme/1ad3ba04ef2674b0fa1f7ce60f443c10c5b23929/scheme.wasm.ui/fonts/roboto-v29-latin-regular.woff -------------------------------------------------------------------------------- /scheme.wasm.ui/fonts/roboto-v29-latin-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PollRobots/scheme/1ad3ba04ef2674b0fa1f7ce60f443c10c5b23929/scheme.wasm.ui/fonts/roboto-v29-latin-regular.woff2 -------------------------------------------------------------------------------- /scheme.wasm.ui/fonts/source-code-pro-v18-latin-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PollRobots/scheme/1ad3ba04ef2674b0fa1f7ce60f443c10c5b23929/scheme.wasm.ui/fonts/source-code-pro-v18-latin-regular.woff -------------------------------------------------------------------------------- /scheme.wasm.ui/fonts/source-code-pro-v18-latin-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PollRobots/scheme/1ad3ba04ef2674b0fa1f7ce60f443c10c5b23929/scheme.wasm.ui/fonts/source-code-pro-v18-latin-regular.woff2 -------------------------------------------------------------------------------- /scheme.wasm.ui/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | scheme.wasm 8 | 9 | 10 | 11 | 37 | 80 | 81 | 82 | 83 |
84 | 85 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /scheme.wasm.ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "scheme.wasm.ui", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "webpack server --mode development --no-hot", 8 | "start-prod": "webpack server --mode production --no-hot", 9 | "build-prod": "webpack --mode production", 10 | "build-dev": "webpack --mode development", 11 | "clean": "rimraf -rf ./dist", 12 | "test": "echo \"Error: no test specified\" && exit 1" 13 | }, 14 | "keywords": [], 15 | "author": "Paul C Roberts ", 16 | "license": "MIT", 17 | "devDependencies": { 18 | "@types/prismjs": "^1.16.6", 19 | "@types/react": "^17.0.37", 20 | "@types/react-dom": "^17.0.11", 21 | "@types/sanitize-html": "^2.6.0", 22 | "@types/ua-parser-js": "^0.7.36", 23 | "@types/wicg-file-system-access": "^2020.9.4", 24 | "clean-webpack-plugin": "^4.0.0", 25 | "copy-webpack-plugin": "^10.1.0", 26 | "css-loader": "^6.5.1", 27 | "fflate": "^0.7.3", 28 | "file-loader": "^6.2.0", 29 | "generate-file-webpack-plugin": "^1.0.1", 30 | "html-webpack-plugin": "^5.5.0", 31 | "monaco-editor": "^0.31.1", 32 | "prismjs": "^1.25.0", 33 | "react-contenteditable": "^3.3.6", 34 | "sanitize-html": "^2.6.1", 35 | "scheme.wasm": "file:../scheme.wasm", 36 | "source-map-loader": "^3.0.0", 37 | "style-loader": "^3.3.1", 38 | "terser-webpack-plugin": "^5.3.0", 39 | "ts-loader": "^9.2.6", 40 | "typescript": "^4.5.3", 41 | "ua-parser-js": "^1.0.2", 42 | "webpack": "^5.65.0", 43 | "webpack-bundle-analyzer": "^4.5.0", 44 | "webpack-cli": "^4.9.1", 45 | "webpack-dev-server": "^4.6.0", 46 | "webpack-subresource-integrity": "^5.1.0" 47 | }, 48 | "dependencies": { 49 | "react": "^17.0.2", 50 | "react-dom": "^17.0.2" 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /scheme.wasm.ui/src/Jiffies.ts: -------------------------------------------------------------------------------- 1 | export class Jiffies { 2 | private readonly epoch: number; 3 | private microsPerJiffy: number; 4 | 5 | private constructor(epoch: number, microsPerJiffy: number) { 6 | this.epoch = epoch; 7 | this.microsPerJiffy = microsPerJiffy; 8 | console.log(`One jiffy is ${microsPerJiffy}μs`); 9 | } 10 | 11 | get jiffiesPerSecond(): number { 12 | return 1000000 / this.microsPerJiffy; 13 | } 14 | 15 | get current(): number { 16 | return Math.round( 17 | (1000 * (performance.now() - this.epoch)) / this.microsPerJiffy 18 | ); 19 | } 20 | 21 | static init(): Jiffies { 22 | const intervals = new Set(); 23 | 24 | let last = performance.now(); 25 | for (let i = 0; i < 100 && intervals.size < 2; i++) { 26 | const curr = performance.now(); 27 | intervals.add(Math.round(1000 * (curr - last))); 28 | last = curr; 29 | } 30 | 31 | let smallest = Infinity; 32 | for (const interval of intervals) { 33 | if (interval > 0 && interval < smallest) { 34 | smallest = interval; 35 | } 36 | } 37 | 38 | return new Jiffies(performance.now(), smallest); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /scheme.wasm.ui/src/SchemeType.tsx: -------------------------------------------------------------------------------- 1 | export enum SchemeType { 2 | Empty = 0, 3 | Nil = 1, 4 | Boolean = 2, 5 | Cons = 3, 6 | I64 = 4, 7 | F64 = 5, 8 | Symbol = 6, 9 | Str = 7, 10 | Char = 8, 11 | Env = 9, 12 | Special = 10, 13 | Builtin = 11, 14 | Lambda = 12, 15 | Error = 13, 16 | Values = 14, 17 | Vector = 15, 18 | Bytevector = 16, 19 | Cont = 17, 20 | BigInt = 18, 21 | Except = 19, 22 | ContProc = 20, 23 | SyntaxRules = 21, 24 | Rational = 22, 25 | Complex = 23, 26 | Record = 24, 27 | RecordMeta = 25, 28 | RecordMethod = 26, 29 | CaseLambda = 27, 30 | Port = 28, 31 | Eof = 29, 32 | MaxHeap = 30, 33 | Mask = 0x1f, 34 | } 35 | -------------------------------------------------------------------------------- /scheme.wasm.ui/src/components/About.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { ThemeContext } from "./ThemeProvider"; 3 | import "../styles/animations.module.css"; 4 | import { reference } from "../util"; 5 | import animations from "../styles/animations.module.css"; 6 | 7 | reference(animations); 8 | 9 | interface AboutState { 10 | loaded: boolean; 11 | } 12 | 13 | export const About: React.FunctionComponent = (props) => { 14 | const theme = React.useContext(ThemeContext); 15 | const [state, setState] = React.useState({ loaded: false }); 16 | 17 | return ( 18 |
33 |