Commit eef6e420 authored by John van Groningen's avatar John van Groningen
Browse files

add foreign export

parent 8c7cfaa8
......@@ -413,6 +413,7 @@ BEDeclareIclModule (CleanString name, CleanString modificationTime, int nFunctio
iclModule->im_imported_objs = NULL;
iclModule->im_imported_libs = NULL;
# endif
iclModule->im_foreign_exports=NULL;
CurrentModule = cName;
......@@ -3057,6 +3058,20 @@ BEDefineImportedObjsAndLibs (BEStringListP objs, BEStringListP libs)
gBEState.be_icl.beicl_module->im_imported_libs = libs;
} /* BEDefineRules */
void BEInsertForeignExport (BESymbolP symbol_p)
{
ImpMod icl_mod_p;
struct foreign_export_list *foreign_export_list_p;
foreign_export_list_p=ConvertAllocType (struct foreign_export_list);
icl_mod_p=gBEState.be_icl.beicl_module;
foreign_export_list_p->fe_symbol_p=symbol_p;
foreign_export_list_p->fe_next=icl_mod_p->im_foreign_exports;
icl_mod_p->im_foreign_exports=foreign_export_list_p;
}
BEStringListP
BEString (CleanString cleanString)
{
......
......@@ -532,6 +532,9 @@ Clean (BEExportFunction :: Int BackEnd -> BackEnd)
void BEDefineImportedObjsAndLibs (BEStringListP objs, BEStringListP libs);
Clean (BEDefineImportedObjsAndLibs :: BEStringListP BEStringListP BackEnd -> BackEnd)
void BEInsertForeignExport (BESymbolP symbol_p);
Clean (BEInsertForeignExport :: BESymbolP BackEnd -> BackEnd)
void BESetMainDclModuleN (int main_dcl_module_n_parameter);
Clean (BESetMainDclModuleN :: Int BackEnd -> BackEnd)
......
......@@ -1242,6 +1242,8 @@ void CodeGeneration (ImpMod imod, char *fname)
GenerateCodeForConstructorsAndRecords (imod->im_symbols);
GenerateForeignExports (imod->im_foreign_exports);
if (imod->im_start)
GenStart (imod->im_start);
ExitOnInterrupt ();
......
......@@ -22,6 +22,8 @@
#include "statesgen.h"
#include "version.h"
#define for_l(v,l,n) for(v=(l);v!=NULL;v=v->n)
#define BINARY_ABC 0
#undef MEMORY_PROFILING_WITH_N_STRING
......@@ -3522,6 +3524,55 @@ void GenSystemImports (void)
}
}
static void print_foreign_export_type (TypeNode type)
{
if (!type->type_node_is_var){
Symbol symbol_p;
symbol_p=type->type_node_symbol;
if (symbol_p->symb_kind==int_type){
FPrintF (OutFile,"I");
return;
} else if (symbol_p->symb_kind==tuple_type){
TypeArgs type_arg_p;
for_l (type_arg_p,type->type_node_arguments,type_arg_next)
print_foreign_export_type (type_arg_p->type_arg_node);
return;
}
}
error_in_function ("print_foreign_export_type");
}
void GenerateForeignExports (struct foreign_export_list *foreign_export_list)
{
struct foreign_export_list *foreign_export_p;
for_l (foreign_export_p,foreign_export_list,fe_next){
SymbDef function_sdef;
TypeAlt *rule_type_p;
TypeArgs type_arg_p;
function_sdef=foreign_export_p->fe_symbol_p->symb_def;
FPrintF (OutFile,"\n\tcentry %s e_%s_s%s \"",function_sdef->sdef_ident->ident_name,CurrentModule,function_sdef->sdef_ident->ident_name);
rule_type_p=function_sdef->sdef_rule->rule_type;
for_l (type_arg_p,rule_type_p->type_alt_lhs->type_node_arguments,type_arg_next)
print_foreign_export_type (type_arg_p->type_arg_node);
FPrintF (OutFile,":");
print_foreign_export_type (rule_type_p->type_alt_rhs);
FPrintF (OutFile,"\"");
}
}
void GenParameters (Bool input, Parameters params, int asp, int bsp)
{
int is_first_parameter;
......
......@@ -183,6 +183,7 @@ void GenDepend (char *modname);
#endif
void GenEndInfo (void);
void GenSystemImports (void);
void GenerateForeignExports (struct foreign_export_list *foreign_export_p);
void GenStart (SymbDef startsymb);
void InitFileInfo (ImpMod imod);
......
......@@ -815,6 +815,11 @@ struct string_list {
};
#endif
struct foreign_export_list {
SymbolP fe_symbol_p;
struct foreign_export_list *fe_next;
};
#if CLEAN2
typedef char * ModuleFileTime;
#else
......@@ -838,6 +843,7 @@ typedef struct {
struct string_list * im_imported_objs;
struct string_list * im_imported_libs;
#endif
struct foreign_export_list * im_foreign_exports;
#if WRITE_DCL_MODIFICATION_TIME
ModuleFileTime im_modification_time;
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment