Skip to content

Commit

Permalink
Replace old new instantiation with new new instantiation.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed May 23, 2016
1 parent 58bbbff commit 4e18fb9
Show file tree
Hide file tree
Showing 14 changed files with 1,638 additions and 8,470 deletions.
130 changes: 130 additions & 0 deletions Compiler/FrontEnd/NFBinding.mo
@@ -0,0 +1,130 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/


encapsulated package NFBinding
" file: NFMod.mo
package: NFMod
description: A type for bindings in NFInst.
"

public
import SCode;
import DAE;
//import NFEnvScope.ScopeIndex;

protected
import Dump;
import ExpressionDump;

public
uniontype Binding
record UNBOUND end UNBOUND;

record RAW_BINDING
Absyn.Exp bindingExp;
SCode.Final finalPrefix;
SCode.Each eachPrefix;
//ScopeIndex scope;
Integer propagatedDims;
SourceInfo info;
end RAW_BINDING;

record UNTYPED_BINDING
DAE.Exp bindingExp;
Boolean isProcessing;
Integer propagatedDims;
SourceInfo info;
end UNTYPED_BINDING;

record TYPED_BINDING
DAE.Exp bindingExp;
DAE.Type bindingType;
Integer propagatedDims;
SourceInfo info;
end TYPED_BINDING;

public
function fromAbsyn
input Option<Absyn.Exp> inBinding;
input SCode.Final inFinal;
input SCode.Each inEach;
input SourceInfo inInfo;
output Binding outBinding;
algorithm
outBinding := match inBinding
local
Absyn.Exp exp;

case SOME(exp)
then RAW_BINDING(exp, inFinal, inEach, 0, inInfo);

else UNBOUND();
end match;
end fromAbsyn;

function isBound
input Binding inBinding;
output Boolean outIsBound;
algorithm
outIsBound := match inBinding
case UNBOUND() then false;
else true;
end match;
end isBound;

function untypedExp
input Binding inBinding;
output Option<DAE.Exp> outExp;
algorithm
outExp := match inBinding
case UNTYPED_BINDING() then SOME(inBinding.bindingExp);
else NONE();
end match;
end untypedExp;

function toString
input Binding inBinding;
input String inPrefix = "";
output String outString;
algorithm
outString := match inBinding
case UNBOUND() then "";
case RAW_BINDING() then inPrefix + Dump.printExpStr(inBinding.bindingExp);
case UNTYPED_BINDING() then inPrefix + ExpressionDump.printExpStr(inBinding.bindingExp);
case TYPED_BINDING() then inPrefix + ExpressionDump.printExpStr(inBinding.bindingExp);
end match;
end toString;

end Binding;

annotation(__OpenModelica_Interface="frontend");
end NFBinding;
6 changes: 3 additions & 3 deletions Compiler/FrontEnd/NFBuiltin.mo
Expand Up @@ -50,10 +50,10 @@ public constant SCode.Prefixes BUILTIN_PREFIXES = SCode.PREFIXES(
Absyn.NOT_INNER_OUTER(), SCode.NOT_REPLACEABLE());

public constant SCode.Attributes BUILTIN_ATTRIBUTES = SCode.ATTR(
{}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.BIDIR());
{}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.BIDIR(), Absyn.NONFIELD());

public constant SCode.Attributes BUILTIN_CONST_ATTRIBUTES = SCode.ATTR(
{}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.CONST(), Absyn.BIDIR());
{}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.CONST(), Absyn.BIDIR(), Absyn.NONFIELD());

public constant SCode.ClassDef BUILTIN_EMPTY_CLASS = SCode.PARTS(
{}, {}, {}, {}, {}, {}, {}, NONE());
Expand Down Expand Up @@ -233,7 +233,7 @@ public constant SCode.Element BUILTIN_STATESELECT = SCode.CLASS("StateSelect",

// Builtin variable time:
public constant SCode.Element BUILTIN_TIME = SCode.COMPONENT("time", SCode.defaultPrefixes,
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT()),
SCode.ATTR({}, SCode.POTENTIAL(), SCode.NON_PARALLEL(), SCode.VAR(), Absyn.INPUT(), Absyn.NONFIELD()),
Absyn.TPATH(Absyn.IDENT("Real"), NONE()), SCode.NOMOD(), SCode.noComment, NONE(), Absyn.dummyInfo);


Expand Down
64 changes: 64 additions & 0 deletions Compiler/FrontEnd/NFComponent.mo
@@ -0,0 +1,64 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-2014, Open Source Modelica Consortium (OSMC),
* c/o Linköpings universitet, Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3 LICENSE OR
* THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
* RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
* ACCORDING TO RECIPIENTS CHOICE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from OSMC, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/

encapsulated package NFComponent

import SCode.Element;
import DAE.Type;
import NFInstNode.InstNode;
import NFBinding.Binding;

uniontype Component
record COMPONENT_DEF
Element definition;
Integer scope;
end COMPONENT_DEF;

record COMPONENT
String name;
InstNode classInst;
Type ty;
Binding binding;
end COMPONENT;

function name
input Component component;
output String name;
algorithm
name := match component
case COMPONENT_DEF(definition = SCode.COMPONENT(name = name)) then name;
case COMPONENT() then component.name;
end match;
end name;
end Component;

annotation(__OpenModelica_Interface="frontend");
end NFComponent;

0 comments on commit 4e18fb9

Please sign in to comment.