chore(library/init/lean/compiler/ir/emitcpp): small hack for exporting functions as C functions instead of C++
This commit is contained in:
parent
2758681d78
commit
8a3522c8e5
1 changed files with 11 additions and 1 deletions
|
|
@ -125,10 +125,20 @@ do env ← getEnv;
|
|||
def emitCppInitName (n : Name) : M Unit :=
|
||||
toCppInitName n >>= emit
|
||||
|
||||
def isSimpleExportName (n : Name) : M Bool :=
|
||||
do env ← getEnv;
|
||||
match getExportNameFor env n with
|
||||
| some (Name.mkString Name.anonymous s) => pure true
|
||||
| _ => pure false
|
||||
|
||||
def emitFnDeclAux (decl : Decl) (cppBaseName : String) (addExternForConsts : Bool) : M Unit :=
|
||||
do
|
||||
let ps := decl.params;
|
||||
when (ps.isEmpty && addExternForConsts) (emit "extern ");
|
||||
if ps.isEmpty && addExternForConsts then
|
||||
emit "extern "
|
||||
else
|
||||
-- Temporary hack for transitioning to C
|
||||
mwhen (isSimpleExportName decl.name) (emit "extern \"C\" ");
|
||||
emit (toCppType decl.resultType ++ " " ++ cppBaseName);
|
||||
unless (ps.isEmpty) $ do {
|
||||
emit "(";
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue