Skip to content

Commit

Permalink
- added operator (function)? to lexer/parser/walker but is commented …
Browse files Browse the repository at this point in the history
…out.

  we will uncomment it when is needed.
- added operator (function)? to Absyn and SCode (not used as it doesn't come from the 
  lexer/parser/walker)

- split SCode.mo into SCode.mo and SCodeUtil.mo
- remember comments from enumerations, derived, etc from Absyn into SCode

- unified Ceval.cevalCallFunction to handle all types of possible 
  function evaluation: via Cevalfunc, via dll generation, etc.
- enabled Cevalfunc by default in Ceval.cevalCallFunction
- added test for matrix row indexing

- all tests go but meta/BuiltinReal.mo* which displays 
  correct values but in a different way, which I think
  is due to evaluation via Cevalfunc. I disabled it for 
  now.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4536 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Nov 18, 2009
1 parent 30ba5e9 commit 7a44414
Show file tree
Hide file tree
Showing 32 changed files with 2,842 additions and 1,889 deletions.
54 changes: 29 additions & 25 deletions Compiler/Absyn.mo
@@ -1,7 +1,7 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2008, Linköpings University,
* Copyright (c) 1998-2009, Linköpings University,
* Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
Expand Down Expand Up @@ -229,6 +229,7 @@ uniontype ClassDef
record PDER
Path functionName;
list<Ident> vars "derived variables" ;
Option<Comment> comment "comment";
end PDER;

end ClassDef;
Expand Down Expand Up @@ -1020,46 +1021,30 @@ uniontype Restriction "These constructors each correspond to a different kind of
assigned special restrictions.
"
record R_CLASS end R_CLASS;

record R_MODEL end R_MODEL;

record R_RECORD end R_RECORD;

record R_BLOCK end R_BLOCK;

record R_CONNECTOR "connector class"
end R_CONNECTOR;

record R_EXP_CONNECTOR "expandable connector class"
end R_EXP_CONNECTOR;

record R_CONNECTOR "connector class" end R_CONNECTOR;
record R_EXP_CONNECTOR "expandable connector class" end R_EXP_CONNECTOR;
record R_TYPE end R_TYPE;

record R_PACKAGE end R_PACKAGE;

record R_FUNCTION end R_FUNCTION;

record R_OPERATOR "an operator" end R_OPERATOR;
record R_OPERATOR_FUNCTION "an operator function" end R_OPERATOR_FUNCTION;
record R_ENUMERATION end R_ENUMERATION;

record R_PREDEFINED_INT end R_PREDEFINED_INT;

record R_PREDEFINED_REAL end R_PREDEFINED_REAL;

record R_PREDEFINED_STRING end R_PREDEFINED_STRING;

record R_PREDEFINED_BOOL end R_PREDEFINED_BOOL;

record R_PREDEFINED_ENUM end R_PREDEFINED_ENUM;


// MetaModelica
record R_UNIONTYPE "MetaModelica uniontype" end R_UNIONTYPE;

record R_METARECORD "Metamodelica record" //MetaModelica extension, added by simbj
Path name; //Name of the uniontype
Integer index; //Index in the uniontype
end R_METARECORD;

record R_UNKNOWN "Helper restriction" end R_UNKNOWN; /* added by simbj */

end Restriction;

public
Expand Down Expand Up @@ -1826,14 +1811,21 @@ end matchcontinue;
end printImportString;

public function expCref "returns the componentRef of an expression if matches."
input Exp exp;
output ComponentRef cr;
input Exp exp;
output ComponentRef cr;
algorithm
cr := matchcontinue(exp)
case(CREF(cr)) then cr;
end matchcontinue;
end expCref;

public function crefExp "returns the componentRef of an expression if matches."
input ComponentRef cr;
output Exp exp;
algorithm
exp := CREF(cr);
end crefExp;

public function expComponentRefStr ""
input Exp aexp;
output String outString;
Expand Down Expand Up @@ -1916,6 +1908,18 @@ algorithm s := matchcontinue(tp)
end matchcontinue;
end typeSpecPathString;

public function typeSpecPath
"convert TypeSpec to Path"
input TypeSpec tp;
output Path p;
algorithm
p := matchcontinue(tp)
local Path p;
case(TCOMPLEX(path = p)) then p;
case(TPATH(path = p)) then p;
end matchcontinue;
end typeSpecPath;

public function pathString "function: pathString
This function simply converts a Path to a string."
input Path path;
Expand Down
26 changes: 12 additions & 14 deletions Compiler/Builtin.mo
Expand Up @@ -61,19 +61,19 @@ protected import Values;
`Real\', `Integer\' etc.
*/
public constant SCode.Class rlType=SCode.CLASS("RealType",false,false,SCode.R_PREDEFINED_REAL(),
SCode.PARTS({},{},{},{},{},{},NONE)) " real type ";
SCode.PARTS({},{},{},{},{},NONE,{},NONE)) " real type ";

public constant SCode.Class intType=SCode.CLASS("IntegerType",false,false,SCode.R_PREDEFINED_INT(),
SCode.PARTS({},{},{},{},{},{},NONE));
SCode.PARTS({},{},{},{},{},NONE,{},NONE));

public constant SCode.Class strType=SCode.CLASS("StringType",false,false,SCode.R_PREDEFINED_STRING(),
SCode.PARTS({},{},{},{},{},{},NONE));
SCode.PARTS({},{},{},{},{},NONE,{},NONE));

public constant SCode.Class boolType=SCode.CLASS("BooleanType",false,false,SCode.R_PREDEFINED_BOOL(),
SCode.PARTS({},{},{},{},{},{},NONE));
SCode.PARTS({},{},{},{},{},NONE,{},NONE));

protected constant SCode.Class enumType=SCode.CLASS("EnumType",false,false,SCode.R_PREDEFINED_ENUM(),
SCode.PARTS({},{},{},{},{},{},NONE));
SCode.PARTS({},{},{},{},{},NONE,{},NONE));

protected constant SCode.Element unit=SCode.COMPONENT("unit",Absyn.UNSPECIFIED(),true,false,false,
SCode.ATTR({},false,false,SCode.RW(),SCode.PARAM(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("StringType"),NONE),
Expand Down Expand Up @@ -140,25 +140,23 @@ protected constant list<SCode.Element> stateSelectComps={
SCode.ATTR({},false,false,SCode.RO(),SCode.CONST(),Absyn.BIDIR()),Absyn.TPATH(Absyn.IDENT("EnumType"),NONE),SCode.NOMOD(),NONE,NONE,NONE,NONE,NONE)} "The StateSelect enumeration" ;

protected constant SCode.Class stateSelectType=SCode.CLASS("StateSelect",false,false,SCode.R_ENUMERATION(),
SCode.PARTS(stateSelectComps,{},{},{},{},{},NONE)) "The State Select Type" ;
SCode.PARTS(stateSelectComps,{},{},{},{},NONE,{},NONE)) "The State Select Type";

public constant SCode.Class ExternalObjectType=SCode.CLASS("ExternalObject",false,false,SCode.R_CLASS(),
SCode.PARTS(
{},{},{},{},{},{},NONE)) "ExternalObject type" ;
SCode.PARTS({},{},{},{},{},NONE,{},NONE)) "ExternalObject type" ;

public constant SCode.Class realType=SCode.CLASS("Real",false,false,SCode.R_PREDEFINED_REAL(),
SCode.PARTS(
{unit,quantity,displayUnit,min,max,realStart,fixed,nominal,
stateSelect},{},{},{},{},{},NONE)) "- The `Real\' type" ;
SCode.PARTS({unit,quantity,displayUnit,min,max,realStart,fixed,nominal,
stateSelect},{},{},{},{},NONE,{},NONE)) "- The `Real\' type" ;

protected constant SCode.Class integerType=SCode.CLASS("Integer",false,false,SCode.R_PREDEFINED_INT(),
SCode.PARTS({quantity,min,max,integerStart,fixed},{},{},{},{},{},NONE)) "- The `Integer\' type" ;
SCode.PARTS({quantity,min,max,integerStart,fixed},{},{},{},{},NONE,{},NONE)) "- The `Integer\' type" ;

protected constant SCode.Class stringType=SCode.CLASS("String",false,false,SCode.R_PREDEFINED_STRING(),
SCode.PARTS({quantity,stringStart},{},{},{},{},{},NONE)) "- The `String\' type" ;
SCode.PARTS({quantity,stringStart},{},{},{},{},NONE,{},NONE)) "- The `String\' type" ;

protected constant SCode.Class booleanType=SCode.CLASS("Boolean",false,false,SCode.R_PREDEFINED_BOOL(),
SCode.PARTS({quantity,booleanStart,fixed},{},{},{},{},{},NONE)) "- The `Boolean\' type" ;
SCode.PARTS({quantity,booleanStart,fixed},{},{},{},{},NONE,{},NONE)) "- The `Boolean\' type" ;

protected constant DAE.Var timeVar=DAE.TYPES_VAR("time",
DAE.ATTR(false,false,SCode.RO(),SCode.VAR(),Absyn.BIDIR(),Absyn.UNSPECIFIED()),false,(DAE.T_REAL({}),NONE),DAE.UNBOUND()) "- The `time\' variable" ;
Expand Down

0 comments on commit 7a44414

Please sign in to comment.