Skip to content

Commit

Permalink
Array handling is probably broken in this version. Should be fixed in…
Browse files Browse the repository at this point in the history
… next version.

1999-03-19
Multiple return values from functions.

	1999-03-23 Constant propagation in functions.
	With only one output from functions the ouput varaible was
	is consant only if all input parameters are constant.
	With multiple return arguments from functions then some
	output parameters may be constant if some input parameters
	are. This should be checked in the future.

	!! Check inst.rml::inst_eq_equation understand the rule
	evaluation and extend it to multiple return values.

	1999-03-26
	Change of plans. Add  an tuple type instead. This type is
	not in the 1.1 spec. but will probably be there in the future.
	1999-03-27
	constant checking of the tuple�'s arguments is not done at
	the moment. See PROP in staticexp.rml.
	See staticexp.rml
		Write a test and make sure that it passes.
	1999-03-29
	About updating rml code. For example uptadeting
	Properties with Const. The old structure bool still works, just
	code for the extre bool list?
	1999-04-06
Tuples works. But it is not restricted to just functions,
like the modelica 1.1 specification. A bug is that Real x,y;
(x,y)=(1,2); Does not work but (x,y)=(1.0,3.0) works.


1999-04-06
	Type convertion from int to real does not work correctly
	with tuples. Real x,y;  (x,y) = (1,2); does not work.


1999-03-19
Array size allowed in component claus.
	(modelica_1_1_Type9.mo) Write a tests and make sure that
it passes. ok
done 1999-03-23


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@479 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x98petro committed Apr 19, 1999
1 parent 0c96272 commit 55298a3
Show file tree
Hide file tree
Showing 12 changed files with 482 additions and 42 deletions.
4 changes: 3 additions & 1 deletion modeq/Makefile
Expand Up @@ -10,7 +10,9 @@ SHELL = /bin/sh
CC = cc
CFLAGS =
LDFLAGS = -lrml -lm
RML = rmlc -g
#RML = /net/senilix/files/senilix3/labs/pelab/pub/pkg/rml/rml-2.1/sparc-sol2-gcc/bin/rmlc -g
RML = /home/pelab/pub/pkg/rml/rml-2.1.2/sparc-sol2-gcc/bin/rmlc -g
#RML = rmlc -g
PROG = modeq
AST = ast/libast.a
RTOBJ = runtime/rtopts.o
Expand Down
46 changes: 40 additions & 6 deletions modeq/absyn.rml
Expand Up @@ -10,6 +10,8 @@
** (AST), and a few relations for printing the AST.
**)



module Absyn:

type Ident = string
Expand Down Expand Up @@ -58,7 +60,7 @@ module Absyn:
datatype ElementSpec = CLASSDEF of bool (* replaceable *)
* Class
| EXTENDS of Path * ElementArg list
| COMPONENTS of ElementAttributes
| COMPONENTS of ElementAttributes (*1.1 contains Araydim also.*)
* Path (* type name *)
* Component list
(** An element is something that occurs in a public or protected
Expand All @@ -72,7 +74,7 @@ module Absyn:
** `EXTENDS(IDENT("TwoPin"),[])'.
**)

datatype Component = COMPONENT of Ident (* component name *)
datatype Component = COMPONENT of Ident (* component name *)
* ArrayDim
* Modification option
(** Several component declarations can be grouped together in one *)
Expand All @@ -87,6 +89,8 @@ module Absyn:
| EQ_EQUALS of Exp * Exp
| EQ_CONNECT of ComponentRef * ComponentRef
| EQ_FOR of Ident * Exp * Equation list
| EQ_WHEN_E of Exp * Equation list (*1.1*)

(** The `Equation' type describes one equation in an equation *)
(** section. *)

Expand All @@ -95,9 +99,10 @@ module Absyn:
* Algorithm list (* true branch *)
* (Exp * Algorithm list) list (* elseif *)
* Algorithm list (* else branch *)
| ALG_FOR of Ident * Exp * Algorithm list
| ALG_WHILE of Exp * Algorithm list
| ALG_WHEN of Exp * Algorithm list
| ALG_FOR of Ident * Exp * Algorithm list
| ALG_WHILE of Exp * Algorithm list
(* Old 1.0 | ALG_WHEN of Exp * Algorithm list *)
| ALG_WHEN_A of Exp * Algorithm list (*1.1*)
(** The `Algorithm' type describes one algorithm statement in an *)
(** algorithm section. It does not describe a whole algorithm. The *)
(** reason this type is named like this is that the name of the *)
Expand All @@ -116,6 +121,8 @@ module Absyn:
datatype ElementAttributes = ATTR of bool (* flow *)
* Variability (* parameter *)
* Direction
* ArrayDim (*1.1*)

datatype Variability = VAR | DISCRETE | PARAM | CONST
datatype Direction = INPUT | OUTPUT | BIDIR
(** Component attributes are *)
Expand Down Expand Up @@ -146,6 +153,8 @@ module Absyn:
| ARRAY of Exp list
| MATRIX of Exp list list
| RANGE of Exp * Exp option * Exp
| TUPLE of Exp list (*PR.*)

(** The `Exp' datatype is the container of a Modelica expression. *)

datatype Operator = ADD | SUB | MUL | DIV | POW
Expand Down Expand Up @@ -202,7 +211,7 @@ module Absyn:
relation cref_to_path : ComponentRef => Path
relation element_spec_name : ElementSpec => Ident
relation print_restr : Restriction => ()

relation print_absyn_exp : Exp => () (*PR. for debugging.*)
end

(** relation: path_string
Expand Down Expand Up @@ -316,3 +325,28 @@ relation print_restr : Restriction => () =
print_restr R_PREDEFINED_BOOL

end


(* PR. To debug. *)
relation print_absyn_exp : Exp => () =
rule print "This an array: " &
print "[" &

print "]"
---------
print_absyn_exp (ARRAY(es))

(*PR.*)
rule print "(" &

print ")"
---------
print_absyn_exp (TUPLE(es))


rule print "\nNo tuple."
---------
print_absyn_exp (_)


end
8 changes: 4 additions & 4 deletions modeq/algorithm.rml
Expand Up @@ -55,7 +55,7 @@ module Algorithm:
relation make_while : (Exp.Exp, Static.Properties,
Statement list) => Statement

relation make_when : (Exp.Exp, Static.Properties,
relation make_when_a : (Exp.Exp, Static.Properties,
Statement list) => Statement

end
Expand Down Expand Up @@ -188,15 +188,15 @@ end

(** relation: make_when *)

relation make_when : (Exp.Exp, Static.Properties,
relation make_when_a : (Exp.Exp, Static.Properties,
Statement list) => Statement =

axiom make_when(e,Static.PROP(Types.T_BOOL,_),stmts) => WHEN(e,stmts)
axiom make_when_a(e,Static.PROP(Types.T_BOOL,_),stmts) => WHEN(e,stmts)

rule print "# Type error in when conditional.\n" &
print " Expected Boolean, got " &
Types.print_type t & print "\n"
-------------------------------
make_when(_,Static.PROP(t,_),_) => fail
make_when_a(_,Static.PROP(t,_),_) => fail

end
16 changes: 14 additions & 2 deletions modeq/dump.rml
Expand Up @@ -338,10 +338,15 @@ relation print_algorithm: Absyn.Algorithm => () =
----------------------------------------------------------
print_algorithm Absyn.ALG_WHILE(e,al)

rule print "WHEN " & print_exp(e) &
(* rule print "WHEN_E " & print_exp(e) &
print " {" & print_list(al, print_algorithm, ";") & print "}"
----------------------------------------------------------
print_algorithm Absyn.ALG_WHEN(e,al)
print_algorithm Absyn.ALG_WHEN_E(e,al)
*)
rule print "WHEN_A " & print_exp(e) &
print " {" & print_list(al, print_algorithm, ";") & print "}"
----------------------------------------------------------
print_algorithm Absyn.ALG_WHEN_A(e,al)

rule print " ** UNKNOWN ALGORITHM CLAUSE ** "
--------------------------------
Expand Down Expand Up @@ -475,6 +480,13 @@ relation print_exp: Absyn.Exp => () =
print "]"
---------
print_exp Absyn.ARRAY(es)

(* PR. *)
rule print "(" &
print_list(es, print_exp, ",") &
print ")"
---------
print_exp Absyn.TUPLE(es)

rule print "[" &
print_list(es, print_row, ";") &
Expand Down
15 changes: 12 additions & 3 deletions modeq/exp.rml
Expand Up @@ -46,6 +46,7 @@ module Exp:
| ARRAY of Exp list
| MATRIX of Exp list list
| RANGE of Exp * Exp option * Exp
| TUPLE of Exp list (*PR.*)
(* New constructors *)
| CAST of Type * Exp
| ASUB of Exp * int
Expand Down Expand Up @@ -300,15 +301,15 @@ end
** This relation prints a complete expression.
**)

relation print_exp: Exp => () =
relation print_exp : Exp => () =

rule print_exp2 (e,0)
----------------
print_exp e

end

relation print_exp2: (Exp,int) => () =
relation print_exp2 : (Exp,int) => () =

rule int_string(x) => s & print s
----------------------------
Expand Down Expand Up @@ -385,11 +386,19 @@ relation print_exp2: (Exp,int) => () =
---------------------------------------------
print_exp2(CALL(fcn, args),_)

rule print "[" &
rule print "This an array: " &
print "[" &
print_list(es, print_exp, ",") &
print "]"
---------
print_exp2 (ARRAY(es),_)

(*PR.*)
rule print "(" &
print_list(es, print_exp, ",") &
print ")"
---------
print_exp2 (TUPLE(es),_)

rule print "[" &
print_list(es, print_row, ";") &
Expand Down
10 changes: 6 additions & 4 deletions modeq/explode.rml
Expand Up @@ -61,6 +61,7 @@ module SCode :
| EQ_EQUALS of Absyn.Exp * Absyn.Exp
| EQ_CONNECT of Absyn.ComponentRef * Absyn.ComponentRef
| EQ_FOR of Ident * Absyn.Exp * Equation list
| EQ_WHEN of Absyn.Exp * Equation list
(** These are almost identical to the `Absyn' versions. In `EQ_IF', *)
(** the `elseif' branches are represented as normal `else' branches *)
(** with a single `if' statement in them. *)
Expand Down Expand Up @@ -94,7 +95,7 @@ module SCode :
* Accessibility
* Absyn.Variability (* parameter *)
* Absyn.Direction

datatype Accessibility = RW (* read/write *)
| RO (* read-only *)
| WO (* write-only (not used) *)
Expand Down Expand Up @@ -243,12 +244,13 @@ relation elab_elementspec: (bool,bool,Absyn.ElementSpec) => Element list =
axiom elab_elementspec(_,_,Absyn.COMPONENTS(_,_,[])) => []

rule elab_elementspec(final,prot,Absyn.COMPONENTS(attr,t,xs)) => xs' &
build_mod(m,false) => mod
build_mod(m,false) => mod &
list_append(d,ad) => tot_dim
--------------------------------------------------
elab_elementspec(final,prot,
Absyn.COMPONENTS(attr as Absyn.ATTR(fl,pa,di),t,
Absyn.COMPONENTS(attr as Absyn.ATTR(fl,pa,di,ad),t,
(Absyn.COMPONENT(n,d,m))::xs))
=> COMPONENT(n,final,prot,ATTR(d,fl,RW,pa,di),t,mod)::xs'
=> COMPONENT(n,final,prot,ATTR(tot_dim,fl,RW,pa,di),t,mod)::xs'

end

Expand Down

0 comments on commit 55298a3

Please sign in to comment.