Skip to content

Commit

Permalink
Changed DAE.FUNCTION to a more generic structure for external and nor…
Browse files Browse the repository at this point in the history
…mal function as well as derivatives of functions. Construct in front end derivative information for functions.

Inline'ing changed a bit. Now a record rather then a boolean.
Reverted some inst.partialinstclassdef stuff that martin did, was not compatible with all functioncalls. 

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4701 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Björn Zachrisson committed Dec 15, 2009
1 parent 7f64269 commit ba91508
Show file tree
Hide file tree
Showing 17 changed files with 1,303 additions and 809 deletions.
2 changes: 1 addition & 1 deletion Compiler/Algorithm.mo
Expand Up @@ -227,7 +227,7 @@ algorithm
t = getPropExpType(lhprop);
then
DAE.STMT_ASSIGN(t,DAE.CREF(c,crt),rhs_1);
/* TODO: Use this when we have fixed states in DAELow.lower(...)
/* TODO: Use this when we have fixed states in DAELow .lower(...)
case (e1 as DAE.CALL(Absyn.IDENT("der"),{DAE.CREF(_,_)},_,_,_),lhprop,rhs,rhprop)
equation
(rhs_1,_) = Types.matchProp(rhs, rhprop, lhprop);
Expand Down
706 changes: 353 additions & 353 deletions Compiler/Builtin.mo

Large diffs are not rendered by default.

67 changes: 57 additions & 10 deletions Compiler/DAE.mo
Expand Up @@ -45,6 +45,7 @@ public import Absyn;
public import ClassInf;
public import SCode;
public import Values;
//protected import Exp;

public type Ident = String;

Expand Down Expand Up @@ -195,17 +196,11 @@ public uniontype Element

record FUNCTION " A Modelica function"
Absyn.Path path;
DAElist dAElist;
list<FunctionDefinition> functions;
Type type_;
Boolean partialPrefix "MetaModelica extension";
InlineType inlineType;
end FUNCTION;

record EXTFUNCTION "An external function"
Absyn.Path path;
DAElist dAElist;
Type type_;
ExternalDecl externalDecl;
end EXTFUNCTION;

record RECORD_CONSTRUCTOR "A Modelica record constructor. The function can be generated from the Path and Type alone."
Absyn.Path path;
Expand Down Expand Up @@ -239,6 +234,58 @@ public uniontype Element
end NORETCALL;
end Element;

public uniontype InlineType
record NORM_INLINE "Normal inline, inline as soon as possible"
end NORM_INLINE;

record NO_INLINE "Avoid inline, this is default behaviour but is also possible to set with Inline=false"
end NO_INLINE;

record AFTER_INDEX_RED_INLINE "Try to inline after index reduction"
end AFTER_INDEX_RED_INLINE;
end InlineType;

public function convertInlineTypeToBool "
Author: BZ, 2009-12
Function for converting a InlineType to a bool.
Whether the inline takes place before or after index reduction does not mather.
Any kind of inline will result in true.
"
input InlineType it;
output Boolean b;
algorithm b := matchcontinue(it)
case(NO_INLINE) then false;
case(_) then true;
end matchcontinue;
end convertInlineTypeToBool;

public uniontype FunctionDefinition

record FUNCTION_DEF "Normal function body"
DAElist body;
end FUNCTION_DEF;

record FUNCTION_EXT "Normal external function declaration"
DAElist body;
ExternalDecl externalDecl;
end FUNCTION_EXT;

record FUNCTION_DER_MAPPER "Contains derivatives for function"
Absyn.Path derivedFunction "Function that is derived";
Absyn.Path derivativeFunction "Path to derivative function";
Integer derivativeOrder "in case a function have multiple derivatives, include all";
list<tuple<Integer,derivativeCond>> conditionRefs;
Option<Absyn.Path> defaultDerivative "if conditions fails, use default derivative if exists";
list<Absyn.Path> lowerOrderDerivatives;
end FUNCTION_DER_MAPPER;
end FunctionDefinition;

public
uniontype derivativeCond "Different conditions on derivatives"
record ZERO_DERIVATIVE end ZERO_DERIVATIVE;
record NO_DERIVATIVE Exp binding; end NO_DERIVATIVE;
end derivativeCond;

public
uniontype VariableAttributes
record VAR_ATTR_REAL
Expand Down Expand Up @@ -599,7 +646,7 @@ uniontype TType "-TType contains the actual type"
record T_FUNCTION
list<FuncArg> funcArg "funcArg" ;
Type funcResultType "funcResultType ; Only single-result" ;
Boolean inline;
InlineType inline;
end T_FUNCTION;

record T_TUPLE
Expand Down Expand Up @@ -886,7 +933,7 @@ uniontype Exp "Expressions
Boolean tuple_ "tuple" ;
Boolean builtin "builtin Function call" ;
ExpType ty "The type of the return value, if several return values this is undefined";
Boolean inline;
InlineType inlineType;
end CALL;

record PARTEVALFUNCTION
Expand Down

0 comments on commit ba91508

Please sign in to comment.