转换的JavaScript code到c code [英] Convert javascript code to c code

查看:162
本文介绍了转换的JavaScript code到c code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法到C code转换为JavaScript和从JavaScript到C?我发现 V8果汁可生成C ++ JavaScript的侧类,但它只有一个方法(C ++中的JavaScript)

Is there any way to convert C code to JavaScript and from JavaScript to C? I found V8 juice which can generate JavaScript-side classes from C++, but it's only one way (C++ to JavaScript).

我不是在寻找一个软件。

I'm not looking for a software.

推荐答案

非常,非常棘手--- JavaScript是一个沉重的动态语言,其中pretty多少都可以在运行时更改:变量,函数的名称,类型等这样很不好映射到C.而这还不即使考虑的eval(),这将让你构建的Javascript大块任意字符串中并运行它们。

Very, very tricky --- Javascript is a heavily dynamic language where pretty much everything can be changed at run time: names of variables, functions, types, etc. As such it maps very badly onto C. And that's not even considering eval(), which will let you construct arbitrary chunks of Javascript in strings and run them.

任何JavaScript翻译就必须能够应付这样的事情,这意味着它必须给Javascript在运行时转换成C ---这使它成为一个JIT,你已经在使用。

Any Javascript translator would have to be able to cope with such things, which means it would have to translate the Javascript into C at run-time --- which makes it a JIT, which you're already using.

您可能想看看在写C绑定为Javascript来代替。这将使你的Javascript code调出到C code,反之亦然。这将让人们编写插件在C,编译成的.so 共享库,您现在可以加载和你的Javascript code运行。这意味着你不需要翻译任何东西。

You may want to look at writing C bindings for Javascript instead. These will allow your Javascript code to call out to C code and vice versa. This would allow people to write plugins in C, compile them into .so shared libraries, which you can now load and run from your Javascript code. This means you don't need to translate anything.

JavaScript的不是我的领域,所以我不能推荐任何特定的机制,恐怕---但我会非常惊讶,如果V8Juice,你已经找到,没有让你这样做。

Javascript's not my area so I can't recommend any particular mechanism, I'm afraid --- but I'd be very surprised if V8Juice, which you've already found, didn't let you do this.

这篇关于转换的JavaScript code到c code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆