Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract Hedgehog Runtime (transpiler, internal classes Mat and Sym, math and linear algebra functions, preprocessor) as a separate JavaScript runtime & package #41

Open
lidangzzz opened this issue Jul 19, 2020 · 4 comments

Comments

@lidangzzz
Copy link
Member

No description provided.

@promer94
Copy link
Contributor

I have made my attempt at https://github.com/promer94/hedgehog-lab-core

install

npm i hedgehog-lab-core-test babel-template

And use it at my fork

@promer94
Copy link
Contributor

currently, i can't make babel-template being compiled correctly. But if it works, we can write web workers like this.

importScripts("https://unpkg.com/comlink/dist/umd/comlink.js");
importScripts("https://unpkg.com/core/dist/umd/core.js");
const compiler = {
  compile(source) {
    return core.compile(source)
  },
};
Comlink.expose(obj)

you can just use it without installing it and using worker-loader in your webpack

@promer94
Copy link
Contributor

promer94 commented Jul 23, 2020

@lidangzzz can you upgrade babel-template to @babel/template, because i can't compile babel-template correctly but @babel/template works well.
Upgrading to @babel/template will break current operator-overload.js because

path.node.hasOwnProperty('_fromTemplate')

is always false, so recursion will not stop.

And i found a operator-overload-plugin might help you to rewrite the current code

@lidangzzz
Copy link
Member Author

Hi @promer94 ,

I will try to upgrade babel template later, could you explain a little bit more about what's the compiling error? Also my implementation of operator overload is TOTALLY different from Rob's implementation( https://github.com/rob-blackbourn/babel-operator-overload-plugin ). Here are all scenarios that we need to consider:

Mat_object [op] Mat_object

Mat_object [op] scalar

Mat_object [op] 1D/2D_array_of_number

number [op] Mat_object

1D/2D Array of number [op] Mat_object

Sym_object [op] scalar

scalar [op] Sym_object

Sym_object [op] Sym_object

So when we are trying to implement a Babel plugin, it's NOT an operator overload of ClassFoo [op] ClassFoo. Instead it should always cover all possible combination above.

Here is a reference: https://zhuanlan.zhihu.com/p/159128811

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

No branches or pull requests

2 participants