Skip to content

Commit

Permalink
- Builtin functions no longer use the weird _rettype crap
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9868 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Sep 19, 2011
1 parent ff88eca commit 9ef59e2
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 243 deletions.
10 changes: 8 additions & 2 deletions Compiler/FrontEnd/ExpressionDump.mo
Expand Up @@ -57,6 +57,7 @@ public type Var = DAE.ExpVar;
protected import ComponentReference;
protected import DAEDump;
protected import Dump;
protected import Error;
protected import Expression;
protected import Patternm;
protected import RTOpts;
Expand Down Expand Up @@ -131,9 +132,14 @@ algorithm

case (DAE.ET_METATYPE()) then "METATYPE";
case (DAE.ET_BOXED(_)) then "BOXED";
case (DAE.ET_NORETCALL()) then "ET_NORETCALL";
case (DAE.ET_FUNCTION_REFERENCE_VAR()) then "ET_FUNCTION_REFERENCE_VAR";
case (DAE.ET_FUNCTION_REFERENCE_FUNC(builtin=_)) then "ET_FUNCTION_REFERENCE_FUNC";

case(_) then "#ExpressionDump.typeString failed#";

else
equation
Error.addMessage(Error.INTERNAL_ERROR,{"ExpressionDump.typeString failed"});
then "#ExpressionDump.typeString failed#";
end matchcontinue;
end typeString;

Expand Down
22 changes: 3 additions & 19 deletions Compiler/susan_codegen/SimCode/SimCodeC.tpl
Expand Up @@ -5366,7 +5366,9 @@ template daeExpCall(Exp call, Context context, Text &preExp /*BUFP*/,
case exp as CALL(attr=attr as CALL_ATTR(__)) then
let argStr = (expLst |> exp => '<%daeExp(exp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/)%>' ;separator=", ")
let funName = '<%underscorePath(path)%>'
let retType = '<%funName%>_rettype'
let retType = if attr.builtin then (match attr.ty case ET_NORETCALL(__) then ""
else expTypeModelica(attr.ty))
else '<%funName%>_rettype'
let retVar = match attr.ty
case ET_NORETCALL(__) then ""
else tempDecl(retType, &varDecls)
Expand Down Expand Up @@ -6062,24 +6064,6 @@ template tempDecl(String ty, Text &varDecls /*BUFP*/)
case "modelica_metatype"
case "metamodelica_string"
case "metamodelica_string_const"
case "stringListStringChar_rettype"
case "stringAppendList_rettype"
case "stringGetStringChar_rettype"
case "stringUpdateStringChar_rettype"
case "listReverse_rettype"
case "listAppend_rettype"
case "listGet_rettype"
case "listDelete_rettype"
case "listRest_rettype"
case "listFirst_rettype"
case "arrayGet_rettype"
case "arrayCreate_rettype"
case "arrayList_rettype"
case "listArray_rettype"
case "arrayUpdate_rettype"
case "arrayCopy_rettype"
case "arrayAdd_rettype"
case "getGlobalRoot_rettype"
then 'tmpMeta[<%System.tmpTickIndex(1)%>]'
else
let newVarIx = 'tmp<%System.tmpTick()%>'
Expand Down
1 change: 0 additions & 1 deletion c_runtime/boolean_array.h
Expand Up @@ -159,7 +159,6 @@ static inline int ndims_boolean_array(boolean_array_t* a)
{ return ndims_base_array(a); }
static inline int size_of_dimension_boolean_array(boolean_array_t a, int i)
{ return size_of_dimension_base_array(a, i); }
typedef modelica_integer size_of_dimension_boolean_array_rettype;
static inline modelica_boolean *data_of_boolean_array(boolean_array_t *a)
{ return (modelica_boolean *) a->data; }

Expand Down
4 changes: 2 additions & 2 deletions c_runtime/dummy_model.cpp
Expand Up @@ -534,7 +534,7 @@ int function_updateDepend()
modelica_boolean tmp0;
modelica_boolean tmp1;
modelica_boolean tmp2;
edge_rettype tmp3;
modelica_boolean tmp3;
modelica_boolean tmp4;
modelica_real tmp5;
modelica_real tmp6;
Expand Down Expand Up @@ -639,7 +639,7 @@ int function_storeDelayed()

int function_when(int i)
{
edge_rettype tmp0;
modelica_boolean tmp0;
modelica_boolean tmp1;
modelica_real tmp2;
modelica_real tmp3;
Expand Down
1 change: 0 additions & 1 deletion c_runtime/integer_array.h
Expand Up @@ -222,7 +222,6 @@ static inline int ndims_integer_array(integer_array_t* a)
{ return ndims_base_array(a); }
static inline int size_of_dimension_integer_array(integer_array_t a, int i)
{ return size_of_dimension_base_array(a, i); }
typedef modelica_integer size_of_dimension_integer_array_rettype;

void size_integer_array(integer_array_t* a,integer_array_t* dest);
modelica_integer scalar_integer_array(integer_array_t* a);
Expand Down
24 changes: 1 addition & 23 deletions c_runtime/meta/meta_modelica.c
Expand Up @@ -85,7 +85,7 @@ void *mmc_mk_box_no_assign(int slots, unsigned ctor)
return MMC_TAGPTR(p);
}

valueEq_rettype valueEq(modelica_metatype lhs, modelica_metatype rhs)
modelica_boolean valueEq(modelica_metatype lhs, modelica_metatype rhs)
{
mmc_uint_t h_lhs;
mmc_uint_t h_rhs;
Expand Down Expand Up @@ -176,28 +176,6 @@ valueEq_rettype valueEq(modelica_metatype lhs, modelica_metatype rhs)
EXIT(1);
}

/*
mmc__uniontype__metarecord__typedef__equal_rettype
mmc__uniontype__metarecord__typedef__equal(void* ut,int ex_ctor,int fieldNums)
{
mmc_uint_t hdr;
int numslots;
unsigned ctor;
struct record_description* desc;
hdr = MMC_GETHDR(ut);
numslots = MMC_HDRSLOTS(hdr);
ctor = 255 & (hdr >> 2);
if (numslots == fieldNums+1 && ctor == ex_ctor+3) { // RECORD
desc = MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(ut),1));
return 1;
} else {
return 0;
}
}
*/

void debug__print(void* prefix, void* any)
{
fprintf(stderr, "%s%s", MMC_STRINGDATA(prefix), anyString(any));
Expand Down
14 changes: 2 additions & 12 deletions c_runtime/meta/meta_modelica.h
Expand Up @@ -408,20 +408,15 @@ static inline void *mmc_mk_some(const void *x)
void *mmc_mk_box_arr(int slots, unsigned ctor, const void** args);
void *mmc_mk_box_no_assign(int slots, unsigned ctor);

typedef modelica_integer valueEq_rettype;
valueEq_rettype valueEq(modelica_metatype,modelica_metatype);
modelica_boolean valueEq(modelica_metatype,modelica_metatype);
modelica_metatype boxptr_valueEq(modelica_metatype,modelica_metatype);

typedef modelica_integer valueHashMod_rettype;
valueHashMod_rettype valueHashMod(modelica_metatype,modelica_integer);
modelica_integer valueHashMod(modelica_metatype,modelica_integer);
void* boxptr_valueHashMod(void *p, void *mod);

void mmc__unbox(modelica_metatype box, void* res);

typedef modelica_boolean mmc__uniontype__metarecord__typedef__equal_rettype;
#define mmc__uniontype__metarecord__typedef__equal(UT,CTOR,NFIELDS) (MMC_GETHDR(UT)==MMC_STRUCTHDR(NFIELDS+1,CTOR+3))
/* mmc__uniontype__metarecord__typedef__equal_rettype mmc__uniontype__metarecord__typedef__equal(void*,int,int); */
typedef modelica_string anyString_rettype;

void debug__print(void*,void*); /* For debugging */
void initializeStringBuffer();
Expand Down Expand Up @@ -449,11 +444,6 @@ struct record_description {
};

/* Unboxing */
typedef modelica_integer mmc__unbox__integer_rettype;
typedef modelica_real mmc__unbox__real_rettype;
typedef modelica_string_t mmc__unbox__string_rettype;
typedef base_array_t mmc__unbox__array_rettype;

#define mmc_mk_integer mmc_mk_icon
#define mmc_mk_boolean mmc_mk_bcon
#define mmc_mk_real mmc_mk_rcon
Expand Down

0 comments on commit 9ef59e2

Please sign in to comment.