将 C 翻译成 JavaScript

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4210797/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 11:23:49  来源:igfitidea点击:

Translating C to JavaScript

javascriptccode-translation

提问by janesconference

I've got a bunch of math/dsp algorithms in C. Single functions, one function per file, no fancy linking or includes or preprocessor directives, only c99 and standard library calls (mainly memset and memmoves to handle array copying etc). Translating them is not a big problem, but it takes time. I was wondering if there was some C -> Javascript translation tool, in order to speed up the work.

我在 C 中有一堆数学/DSP 算法。单个函数,每个文件一个函数,没有花哨的链接或包含或预处理器指令,只有 c99 和标准库调用(主要是 memset 和 memmoves 来处理数组复制等)。翻译它们不是大问题,但需要时间。我想知道是否有一些 C -> Javascript 翻译工具,以加快工作速度。

Please mind I don't need a perfect translation, I will put my hand on the final result anyway. What I need is a simple tool that helps with the basic, "boring" things.

请注意,我不需要完美的翻译,无论如何我都会决定最终结果。我需要的是一个简单的工具来帮助处理基本的“无聊”的事情。

Anyone heard of such a thing?

有人听说过这样的事情吗?

Edit: seems that emscripten will do the trick.

编辑:似乎 emscripten 会解决问题。

回答by gblazex

Update: it seems The Times They Are a-Changin' :)

更新:似乎他们正在改变的时代 :)

See this article: DOOM Ported to JavaScript and HTML5

请参阅本文:DOOM 移植到 JavaScript 和 HTML5

Zakai compiled the DOOM source code from C to JavaScript using Emscriptenand Clangand optimized it with Closure Compiler.

Zakai 使用EmscriptenClang将 DOOM 源代码从 C 编译为 JavaScript ,并使用 Closure Compiler 对其进行优化。

And here is the Project page. Have fun! :)

这是项目页面。玩得开心!:)

回答by janesconference

FYI, Emscriptendoes exactly that.

仅供参考,Emscripten正是这样做的。