Skip to content

Commit

Permalink
- Added Absyn.Info to Absyn.REDECLARE and updated SCodeUtil
Browse files Browse the repository at this point in the history
- Fixed a bug in ExpressionSolve.mo


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7801 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Jan 27, 2011
1 parent d68edcf commit df8e10c
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 39 deletions.
2 changes: 1 addition & 1 deletion Compiler/BackEnd/ExpressionSolve.mo
Expand Up @@ -149,7 +149,7 @@ public function solveLin
output DAE.Exp outExp;
output list<DAE.Statement> outAsserts;
algorithm
outExp := matchcontinue (inExp1,inExp2,inExp3)
(outExp,outAsserts) := matchcontinue (inExp1,inExp2,inExp3)
local
DAE.Exp crexp,crexp2,rhs,lhs,res,res_1,cr,e1,e2,e3;
DAE.ComponentRef cr1,cr2;
Expand Down
16 changes: 1 addition & 15 deletions Compiler/FrontEnd/Absyn.mo
Expand Up @@ -622,6 +622,7 @@ uniontype ElementArg "Wrapper for things that modify elements, modifications and
Each each_ "each" ;
ElementSpec elementSpec "elementSpec" ;
Option<ConstrainClass> constrainClass "class definition or declaration" ;
Info info "needed because ElementSpec does not contain this info; Element does";
end REDECLARATION;

end ElementArg;
Expand Down Expand Up @@ -2229,21 +2230,6 @@ algorithm
end match;
end elementSpecName;

public function elementSpecInfo
"Extracts the Absyn.Info for an ElementSpec. At the moment it just returns
dummyInfo for components, because they do not contain any info yet."
input ElementSpec inElementSpec;
output Info outInfo;
algorithm
outInfo := match(inElementSpec)
local
Info info;

case CLASSDEF(class_ = CLASS(info = info)) then info;
case COMPONENTS(components = _) then dummyInfo;
end match;
end elementSpecInfo;

public function printImportString "Function: printImportString
This function takes a Absyn.Import and prints it as a flat-string.
"
Expand Down
5 changes: 4 additions & 1 deletion Compiler/FrontEnd/Dump.mo
Expand Up @@ -6420,6 +6420,7 @@ algorithm
Absyn.RedeclareKeywords redeclareKeywords;
Absyn.ElementSpec elementSpec;
Option<Absyn.ConstrainClass> constrainClass;
Absyn.Info info;
case Absyn.MODIFICATION(finalItem,each_,componentRef,modification,comment)
equation
Print.printBuf("record Absyn.MODIFICATION finalItem = ");
Expand All @@ -6434,7 +6435,7 @@ algorithm
printStringCommentOption(comment);
Print.printBuf(" end Absyn.MODIFICATION;");
then ();
case Absyn.REDECLARATION(finalItem,redeclareKeywords,each_,elementSpec,constrainClass)
case Absyn.REDECLARATION(finalItem,redeclareKeywords,each_,elementSpec,constrainClass,info)
equation
Print.printBuf("record Absyn.REDECLARATION finalItem = ");
Print.printBuf(Util.if_(finalItem,"true","false"));
Expand All @@ -6446,6 +6447,8 @@ algorithm
printElementSpecAsCorbaString(elementSpec);
Print.printBuf(", constrainClass = ");
printOption(constrainClass, printConstrainClassAsCorbaString);
Print.printBuf(", info = ");
printInfoAsCorbaString(info);
Print.printBuf(" end Absyn.REDECLARATION;");
then ();
end match;
Expand Down
3 changes: 1 addition & 2 deletions Compiler/FrontEnd/SCodeUtil.mo
Expand Up @@ -1469,11 +1469,10 @@ algorithm
then
(sub :: subs);

case ((Absyn.REDECLARATION(finalItem = finalPrefix,redeclareKeywords = keywords,each_ = each_,elementSpec = spec,constrainClass = constropt) :: xs))
case ((Absyn.REDECLARATION(finalItem = finalPrefix,redeclareKeywords = keywords,each_ = each_,elementSpec = spec,constrainClass = constropt, info = info) :: xs))
equation
subs = translateArgs(xs);
n = Absyn.elementSpecName(spec);
info = Absyn.elementSpecInfo(spec);
elist = translateElementspec(constropt,finalPrefix, Absyn.UNSPECIFIED(),NONE(), false, spec, info)
"LS:: do not know what to use for *protected*, so using false
LS:: do not know what to use for *replaceable*, so using false" ;
Expand Down
6 changes: 3 additions & 3 deletions Compiler/OpenModelicaBootstrappingHeader.h
Expand Up @@ -1645,7 +1645,7 @@ extern struct record_description Absyn_ElementArg_MODIFICATION__desc;
#ifdef ADD_METARECORD_DEFINTIONS
#ifndef Absyn_ElementArg_REDECLARATION__desc_added
#define Absyn_ElementArg_REDECLARATION__desc_added
const char* Absyn_ElementArg_REDECLARATION__desc__fields[5] = {"finalItem","redeclareKeywords","each_","elementSpec","constrainClass"};
const char* Absyn_ElementArg_REDECLARATION__desc__fields[6] = {"finalItem","redeclareKeywords","each_","elementSpec","constrainClass","info"};
struct record_description Absyn_ElementArg_REDECLARATION__desc = {
"Absyn_ElementArg_REDECLARATION",
"Absyn.ElementArg.REDECLARATION",
Expand All @@ -1655,8 +1655,8 @@ struct record_description Absyn_ElementArg_REDECLARATION__desc = {
#else /* Only use the file as a header */
extern struct record_description Absyn_ElementArg_REDECLARATION__desc;
#endif
#define Absyn__REDECLARATION_3dBOX5 4
#define Absyn__REDECLARATION(finalItem,redeclareKeywords,each_,elementSpec,constrainClass) (mmc_mk_box6(4,&Absyn_ElementArg_REDECLARATION__desc,finalItem,redeclareKeywords,each_,elementSpec,constrainClass))
#define Absyn__REDECLARATION_3dBOX6 4
#define Absyn__REDECLARATION(finalItem,redeclareKeywords,each_,elementSpec,constrainClass,info) (mmc_mk_box7(4,&Absyn_ElementArg_REDECLARATION__desc,finalItem,redeclareKeywords,each_,elementSpec,constrainClass,info))
#ifdef ADD_METARECORD_DEFINTIONS
#ifndef Absyn_RedeclareKeywords_REDECLARE__desc_added
#define Absyn_RedeclareKeywords_REDECLARE__desc_added
Expand Down
8 changes: 4 additions & 4 deletions Compiler/Script/Interactive.mo
Expand Up @@ -3226,18 +3226,18 @@ algorithm
cr_1 = replaceStartInComponentRef(cr, old_comp, new_comp);
then
Absyn.MODIFICATION(b,each_,cr_1,NONE(),str);
case (Absyn.REDECLARATION(finalItem = b,redeclareKeywords = redecl,each_ = each_,elementSpec = element_spec,constrainClass = SOME(Absyn.CONSTRAINCLASS(element_spec2,c))),old_comp,new_comp)
case (Absyn.REDECLARATION(finalItem = b,redeclareKeywords = redecl,each_ = each_,elementSpec = element_spec,constrainClass = SOME(Absyn.CONSTRAINCLASS(element_spec2,c)),info = info),old_comp,new_comp)
equation
element_spec_1 = renameComponentInElementSpec(element_spec, old_comp, new_comp);
element_spec2_1 = renameComponentInElementSpec(element_spec2, old_comp, new_comp);
then
Absyn.REDECLARATION(b,redecl,each_,element_spec_1,
SOME(Absyn.CONSTRAINCLASS(element_spec2_1,c)));
case (Absyn.REDECLARATION(finalItem = b,redeclareKeywords = redecl,each_ = each_,elementSpec = element_spec,constrainClass = NONE()),old_comp,new_comp)
SOME(Absyn.CONSTRAINCLASS(element_spec2_1,c)),info);
case (Absyn.REDECLARATION(finalItem = b,redeclareKeywords = redecl,each_ = each_,elementSpec = element_spec,constrainClass = NONE(),info=info),old_comp,new_comp)
equation
element_spec_1 = renameComponentInElementSpec(element_spec, old_comp, new_comp);
then
Absyn.REDECLARATION(b,redecl,each_,element_spec_1,NONE());
Absyn.REDECLARATION(b,redecl,each_,element_spec_1,NONE(),info);
end match;
end renameComponentInElementArg;

Expand Down
24 changes: 12 additions & 12 deletions Parser/Modelica.g
Expand Up @@ -517,15 +517,15 @@ argument_list returns [void* ast] :
;

argument returns [void* ast] :
( em=element_modification_or_replaceable {ast = em;}
| er=element_redeclaration {ast = er;}
( em=element_modification_or_replaceable {$ast = $em.ast;}
| er=element_redeclaration {$ast = $er.ast;}
)
;

element_modification_or_replaceable returns [void* ast] :
(e=EACH)? (f=FINAL)? (em=element_modification[e ? Absyn__EACH : Absyn__NON_5fEACH, mk_bcon(f)] | er=element_replaceable[e != NULL,f != NULL,false])
{
ast = em ? em : er;
ast = $em.ast ? $em.ast : $er.ast;
}
;

Expand All @@ -537,22 +537,22 @@ element_redeclaration returns [void* ast] :
REDECLARE (e=EACH)? (f=FINAL)?
( (cdef=class_definition[f != NULL] | cc=component_clause1) | er=element_replaceable[e != NULL,f != NULL,true] )
{
if (er) {
ast = er;
if ($er.ast) {
$ast = $er.ast;
} else {
if (!cc)
cc = Absyn__CLASSDEF(RML_FALSE,cdef.ast);
ast = Absyn__REDECLARATION(mk_bcon(f), make_redeclare_keywords(false,true), e ? Absyn__EACH : Absyn__NON_5fEACH, cc, mk_none());
$ast = Absyn__REDECLARATION(mk_bcon(f), make_redeclare_keywords(false,true), e ? Absyn__EACH : Absyn__NON_5fEACH, $cc.ast ? $cc.ast : Absyn__CLASSDEF(RML_FALSE,$cdef.ast), mk_none(), INFO($start));
}
}
;

element_replaceable [int each, int final, int redeclare] returns [void* ast] :
element_replaceable [int each, int final, int redeclare] returns [void* ast] @init {
$ast = NULL;
} :
REPLACEABLE ( cd=class_definition[final] | e_spec=component_clause1 ) constr=constraining_clause_comment?
{
ast = Absyn__REDECLARATION(mk_bcon(final), make_redeclare_keywords(true,redeclare),
each ? Absyn__EACH : Absyn__NON_5fEACH, e_spec ? e_spec : Absyn__CLASSDEF(RML_TRUE, cd.ast),
mk_some_or_none($constr.ast));
$ast = Absyn__REDECLARATION(mk_bcon(final), make_redeclare_keywords(true,redeclare),
each ? Absyn__EACH : Absyn__NON_5fEACH, e_spec ? e_spec : Absyn__CLASSDEF(RML_TRUE, $cd.ast),
mk_some_or_none($constr.ast), NULL);
}
;

Expand Down
2 changes: 1 addition & 1 deletion Parser/Parser_omc.cpp
Expand Up @@ -39,7 +39,7 @@ void* Parser_parse(const char* filename)
void *res = parseFile(filename,PARSE_MODELICA);
if (res == NULL)
MMC_THROW();
// printAny(res);
printAny(res);
return res;
}

Expand Down

0 comments on commit df8e10c

Please sign in to comment.