Skip to content

Commit

Permalink
- Extracted record constructors as functions and generated code for them
Browse files Browse the repository at this point in the history
- Generate complex constant expressions in daeExpMetaHelperConstant
- Generate type descriptions for meta types


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5190 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Rickard Lindberg committed Mar 23, 2010
1 parent 547392d commit 2cf0113
Show file tree
Hide file tree
Showing 5 changed files with 2,190 additions and 1,187 deletions.
20 changes: 20 additions & 0 deletions Compiler/SimCode.mo
Expand Up @@ -201,6 +201,11 @@ uniontype Function
String language "C or Fortran";
list<RecordDeclaration> recordDecls;
end EXTERNAL_FUNCTION;
record RECORD_CONSTRUCTOR
Absyn.Path name;
list<Variable> funArgs;
list<RecordDeclaration> recordDecls;
end RECORD_CONSTRUCTOR;
end Function;

uniontype RecordDeclaration
Expand Down Expand Up @@ -766,6 +771,20 @@ algorithm
inVars, outVars, biVars, includes, libs, lang,
recordDecls),
rt_1);
/* Record constructor. */
case (DAE.RECORD_CONSTRUCTOR(path = fpath, type_ = tp as (DAE.T_FUNCTION(funcArg = args,funcResultType = restype as (DAE.T_COMPLEX(complexClassType = ClassInf.RECORD(name)),_)),_)), rt)
local
String defhead, head, foot, body, decl1, decl2, assign_res, ret_var, record_var, record_var_dot, return_stmt;
DAE.ExpType expType;
list<String> arg_names, arg_tmp1, arg_tmp2, arg_assignments;
Integer tnr;
Absyn.Path name;
equation
funArgs = Util.listMap(args, typesSimFunctionArg);
(recordDecls,rt_1) = elaborateRecordDeclarationsForRecord(restype, {}, rt);
then
(RECORD_CONSTRUCTOR(name, funArgs, recordDecls),
rt_1);
case (comp,rt)
equation
Error.addMessage(Error.INTERNAL_ERROR, {"SimCode.elaborateFunction failed"});
Expand Down Expand Up @@ -5004,6 +5023,7 @@ algorithm
{} = DAEUtil.getNamedFunction(path, elements);
pathstr = Absyn.pathString(path);
Error.addMessage(Error.LOOKUP_ERROR, {pathstr,"global scope"});
//Debug.fprintln("failtrace", "SimCode.getCalledFunctionsInFunction: Class " +& pathstr +& " not found in global scope.");
then
path::acc;

Expand Down

0 comments on commit 2cf0113

Please sign in to comment.