简体   繁体   English

Haxe编译为C ++和JS源代码

[英]Haxe compiling to C++ and JS source

I am trying to write source code in one language and have it converted to both native c++ and JS source. 我正在尝试用一种语言编写源代码,并将其转换为本地c ++和JS源。 Ideally the converted source should be human readable and resemble the original source as best it can. 理想情况下,转换后的源应该是人类可读的,并且尽可能地类似于原始源。 I was hoping haxe could solve this problem for me. 我希望haxe可以为我解决这个问题。 So I code in haxescript and have it convert it to its corresponding C++ and JS source. 因此,我使用haxescript进行编码,并将其转换为相应的C ++和JS源代码。 However the examples I'm finding of haxe seems to create the final application for you. 但是,我发现的例子似乎为您创建了最终的应用程序。 So with C++ it will use msbuild (or whatever compiler it finds) and creates the final exe for you from generated C++ code. 因此,对于C ++,它将使用msbuild(或它找到的任何编译器)并根据生成的C ++代码为您创建最终的exe。 Does haxe also create the c++ and JS source code for you to view or is it all done internally to haxe and not accessible? haxe是否还会创建供您查看的c ++和JS源代码,还是在haxe内部完成并且无法访问? If it is accessible then is it possible to remove the building side of haxe so it simply creates the source code and stops? 如果可以访问,那么是否有可能删除haxe的建筑物一侧,使其仅创建源代码并停止?

Thanks 谢谢

When you generate CPP all the intermediate files are generated and kept wherever you decide to generate your output (the path given using -cpp pathToOutput ). 生成CPP时,所有中间文件都会生成并保存在决定生成输出的位置(使用-cpp pathToOutput给出的路径)。 The fact that you get an executable is probably because you are using the -main switch. 获得可执行文件的事实可能是因为您正在使用-main开关。 That implies an entry point to your application but that is not really required and you can just pass to the command line a bunch of types that you want to have built in your output. 这意味着您的应用程序有一个入口点,但这并不是真正需要的,您可以将想要构建在输出中的一堆类型传递给命令行。

For JS it is very similar, a single JS file is generated and it only has an entry point if you used -main . 对于JS,它非常相似,将生成一个JS文件,并且如果使用-main ,则仅具有一个入口点。

Regarding the other topic, does your Haxe code resembles the generated code the answer is yes, but ... some of the types (like Enum and Abstract ) only exist in Haxe so they will generate code that functionally works but it might look quite different. 关于另一个主题,您的Haxe代码是否类似于生成的代码,答案是肯定的,但是...有些类型(例如EnumAbstract )仅存在于Haxe中,因此它们将生成功能上可行的代码,但看起来可能大不相同。 Also Haxe has an always-on optimizer/analyzer that might mungle your code in unexpected ways (the analyzer can be disabled). Haxe还有一个始终在线的优化器/分析器,它可能以意想不到的方式干扰您的代码(可以禁用分析器)。 I still find that it is not that difficult to figure out the Haxe source from the generated code. 我仍然发现从生成的代码中找出Haxe源并不难。 JS has support for source mapping which is really useful for debugging. JS支持源映射,这对于调试非常有用。 So in the end, Haxe doesn't do anything to obfuscate your generated code but also doesn't do much to try to preserve it too strictly. 因此,最后,Haxe不会做任何事情来混淆生成的代码,但是也不会做太多事情来试图严格地保留它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM