Skip to content

Commit

Permalink
Pulling in latest abra_wasm, and updating to use new import syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
kengorab committed Feb 11, 2022
1 parent a080d85 commit 155e74e
Show file tree
Hide file tree
Showing 11 changed files with 17,412 additions and 46 deletions.
17,399 changes: 17,380 additions & 19 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@kengorab/abra_wasm": "^0.6.9",
"@kengorab/abra_wasm": "^0.8.1",
"codemirror": "5.48.0",
"react": "^16.8.6",
"react-codemirror2": "^6.0.0",
Expand Down
Binary file modified public/abra_wasm/abra_wasm_bg.wasm
Binary file not shown.
12 changes: 5 additions & 7 deletions src/components/CodeMirrorEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,11 @@ export default class AbraEditor extends React.Component<Props, State> {
this.setState({ isTypecheckError: true })
onCheck(result.errorMessage.trimStart())

if (result.error.range) {
const { start, end } = result.error.range
const from = { line: start[0] - 1, ch: start[1] - 1 }
const to = { line: end[0] - 1, ch: end[1] }
const mark = editor.getDoc().markText(from, to, { className: 'error-underline' })
this.marks.push(mark)
}
const { start, end } = result.range
const from = { line: start[0] - 1, ch: start[1] - 1 }
const to = { line: end[0] - 1, ch: end[1] }
const mark = editor.getDoc().markText(from, to, { className: 'error-underline' })
this.marks.push(mark)
} else {
onCheck(null)
}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/PlaygroundPage/examples/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
label: 'Enums',
modules: [
{
name: '.enums',
name: './enums',
label: 'enums.abra',
code: `
enum Color {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/PlaygroundPage/examples/fibonacci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
label: 'Fibonacci',
modules: [
{
name: '.fibonacci',
name: './fibonacci',
label: 'fibonacci.abra',
code: `
func fib(n: Int): Int {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/PlaygroundPage/examples/fizzbuzz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
label: 'Fizzbuzz',
modules: [
{
name: '.fizzbuzz',
name: './fizzbuzz',
label: 'fizzbuzz.abra',
code: `
for a in range(1, 101) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/PlaygroundPage/examples/greeting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export default {
label: 'Greeting',
modules: [
{
name: '.greeting',
name: './greeting',
label: 'greeting.abra',
code: `
val greeting = "Hello"
Expand Down
20 changes: 10 additions & 10 deletions src/pages/PlaygroundPage/examples/imports-exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ export default {
label: 'Imports/Exports',
modules: [
{
name: '.main',
name: './main',
label: 'main.abra',
code: `
import Ship from .ship
import Person from .person
import prettyPrint from .util
import Ship from "./ship"
import Person from "./person"
import prettyPrint from "./util"
val ship = Ship(
name: "Planet Express Ship",
Expand All @@ -22,7 +22,7 @@ println(prettyPrint(ship))
`.trimStart()
},
{
name: '.person',
name: './person',
label: 'person.abra',
code: `
export type Person {
Expand All @@ -33,10 +33,10 @@ export type Person {
`.trimStart()
},
{
name: '.ship',
name: './ship',
label: 'ship.abra',
code: `
import Person from .person
import Person from "./person"
export type Ship {
name: String
Expand All @@ -45,11 +45,11 @@ export type Ship {
`.trimStart()
},
{
name: '.util',
name: './util',
label: 'util.abra',
code: `
import Ship from .ship
import Person from .person
import Ship from "./ship"
import Person from "./person"
// Ugly prettyPrint function, nothing to see here 🙈
export func prettyPrint(ship: Ship): String {
Expand Down
8 changes: 3 additions & 5 deletions src/pages/PlaygroundPage/examples/linked-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ export default {
label: 'Linked List (ish)',
modules: [
{
name: '.linked_list',
label: 'linked_list.abra',
name: './linked-list',
label: 'linked-list.abra',
code: `
type Node<T> {
value: T
Expand All @@ -28,9 +28,7 @@ type LinkedList<T> {
func map<U>(self, fn: (T) => U): U[] {
val newArr: U[] = []
self.forEach(item => {
newArr.push(fn(item))
})
self.forEach(item => newArr.push(fn(item)))
newArr
}
Expand Down
9 changes: 9 additions & 0 deletions src/pages/PlaygroundPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@ export default class PlaygroundPage extends React.Component<{}, State> {
or try again.
</ConsoleMessage>
)
/*
const moduleLoader = {
resolveModulePath(moduleId: string, _withRespectTo: string) { return moduleId },
readModule(moduleName: string) { return modules[moduleName] },
getModuleName(moduleName: string) { return moduleName }
}
*/

moduleReader = {
resolveModulePath: (moduleId: string, _withRespectTo: string) => moduleId,
readModule: (moduleName: string) => {
const module = this.state.example.modules.find(m => m.name === moduleName)
if (!module) return null
return module.code
},
getModuleName: (moduleName: string) => moduleName,
update: (moduleName: string, code: string) => {
const example = this.state.example
example.modules.find(m => m.name === moduleName)!.code = code
Expand Down

0 comments on commit 155e74e

Please sign in to comment.