11#include " IR.h"
22#include " ../Utils.h"
33
4- IR::IR (std::string libName, std::string packageName)
5- : libName(std::move(libName)), packageName(packageName) {
6- if (this ->libName == " native" ) {
7- /* there are at most 3 objects in the file.
8- * All of them will have distinct names. */
9- libObjectName = " nativeLib" ;
10- } else {
11- libObjectName = this ->libName ;
12- }
4+ IR::IR (std::string libName, std::string objectName, std::string packageName)
5+ : libName(std::move(libName)), objectName(std::move(objectName)),
6+ packageName(packageName) {
137}
148
159void IR::addFunction (std::string name, std::vector<Parameter> parameters,
@@ -55,12 +49,12 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &s, const IR &ir) {
5549 << " import scala.scalanative.native._\n\n " ;
5650 }
5751
58- std::string libObjName = handleReservedWords (ir.libObjectName );
52+ std::string objectName = handleReservedWords (ir.objectName );
5953
6054 if (!ir.libObjEmpty ()) {
6155 s << " @native.link(\" " << ir.libName << " \" )\n "
6256 << " @native.extern\n "
63- << " object " << libObjName << " {\n " ;
57+ << " object " << objectName << " {\n " ;
6458
6559 for (const auto &typeDef : ir.typeDefs ) {
6660 s << typeDef;
@@ -74,7 +68,7 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &s, const IR &ir) {
7468 }
7569
7670 if (!ir.enums .empty () || ir.hasHelperMethods ()) {
77- s << " import " << libObjName << " ._\n\n " ;
71+ s << " import " << objectName << " ._\n\n " ;
7872 }
7973
8074 if (!ir.enums .empty ()) {
0 commit comments