Skip to content

Conversation

@yzia2000
Copy link

@yzia2000 yzia2000 commented May 9, 2021

Copy link
Collaborator

@btzy btzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay in general, but my main concern is the code duplication. The code here will inevitably get out of sync with the one in sourceror-driver, when updates are made to sourceror-driver over time.

Also, do run cargo fmt. It appears that there is some slight misformatting of the rust files.

@@ -0,0 +1 @@
import {math_sin, math_PI} from "https://btzy.github.io/libsourceror/std/math.source";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this file be removed?

Comment on lines +37 to +39
#[wasm_bindgen_test]
fn comp_test() {
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is something supposed to happen here?

Comment on lines +24 to +26

[target."cfg(debug_assertions)".dependencies]
console_error_panic_hook = "0.1.5"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required?

Comment on lines +25 to +27
// Your code goes here!
// const SOURCE_CODE: &'static str = r#"
// { "type": "Program", "start": 0, "end": 65, "body": [ { "type": "FunctionDeclaration", "start": 0, "end": 52, "id": { "type": "Identifier", "start": 9, "end": 11, "name": "ok" }, "expression": false, "generator": false, "async": false, "params": [ { "type": "Identifier", "start": 12, "end": 13, "name": "n" } ], "body": { "type": "BlockStatement", "start": 15, "end": 52, "body": [ { "type": "ReturnStatement", "start": 19, "end": 50, "argument": { "type": "ConditionalExpression", "start": 26, "end": 49, "test": { "type": "BinaryExpression", "start": 26, "end": 33, "left": { "type": "Identifier", "start": 26, "end": 27, "name": "n" }, "operator": "===", "right": { "type": "Literal", "start": 32, "end": 33, "value": 0, "raw": "0" } }, "consequent": { "type": "Literal", "start": 36, "end": 37, "value": 0, "raw": "0" }, "alternate": { "type": "CallExpression", "start": 40, "end": 49, "callee": { "type": "Identifier", "start": 40, "end": 42, "name": "ok" }, "arguments": [ { "type": "BinaryExpression", "start": 43, "end": 48, "left": { "type": "Identifier", "start": 43, "end": 44, "name": "n" }, "operator": "-", "right": { "type": "Literal", "start": 47, "end": 48, "value": 1, "raw": "1" } } ], "optional": false } } } ] } }, { "type": "ExpressionStatement", "start": 54, "end": 64, "expression": { "type": "CallExpression", "start": 54, "end": 63, "callee": { "type": "Identifier", "start": 54, "end": 56, "name": "ok" }, "arguments": [ { "type": "Literal", "start": 57, "end": 62, "value": 50000, "raw": "50000" } ], "optional": false } } ], "sourceType": "script" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this?

Comment on lines +17 to +45
// compile(code, context).then(arr => {
// const startTime = Date.now();
// WebAssembly.instantiate(arr, config)
// .then(({ instance, module }) => {
// const transcoder = new Transcoder();
// transcoder.setMem(new DataView((instance.exports.linear_memory).buffer));
// transcoder.setAllocateStringFunc(instance.exports.allocate_string);
// try {
// (instance.exports.main)();
// const result = read_js_result(
// instance.exports.linear_memory
// );
// const endTime = Date.now()
// const latency = endTime - startTime;
// console.log(`Log: time: ${latency}`)
// logger(result, undefined);
// } catch (e) {
// if (e === {}) {
// logger(undefined, "Runtime error");
// } else {
// logger(undefined, e);
// }
// }
// }, (err) => {
// logger(undefined, err);
// }).catch(err => {
// logger(undefined, err);
// });
// });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this?

[dev-dependencies]
wasm-bindgen-test = "0.2.45"
futures = "0.1.27"
js-sys = "0.3.22"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need to repeat a dev-dependency that is already a normal dependency.


[dependencies]
source-compiler = { path = "../source-compiler" }
js-sys = "0.3.22"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to fix a particular patch version? The other crates in this project do not fix it, and readily accept a version bump. Same for the rest of the dependencies in this file.

/target
/pkg
/wasm-pack.log
package-lock.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also add yarn.lock here, so that people can use yarn to build it too?

@btzy
Copy link
Collaborator

btzy commented Jun 5, 2021

Note that it's possible to add some code into cadet-frontend, if it would help sourceror get rid of the js-slang dependency. You can change the API boundary between cadet-frontend and sourceror as you see fit. I think most of the sourceror-specific stuff in cadet-frontend are in src/commons/sagas/WorkspaceSaga.ts and src/commons/utils/SourcerorHelper.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants