Skip to content

Commit

Permalink
Fixed several bugs with functions, e.g. Real X[:]=Y, etc.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1010 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Oct 23, 2003
1 parent ec4af22 commit 785360c
Show file tree
Hide file tree
Showing 10 changed files with 427 additions and 142 deletions.
7 changes: 7 additions & 0 deletions modeq/classinf.rml
Expand Up @@ -76,6 +76,9 @@ module ClassInf :
(* `assert_valid' is identical to 'valid'. The only difference is *)
(* that it prints an error message when it fails. *)
relation assert_valid : (State, SCode.Restriction) => ()

(* Succeeds if state is FUNCTION *)
relation is_function: State => ()

(* Debug relation *)
relation print_state : State => ()
Expand Down Expand Up @@ -348,3 +351,7 @@ relation assert_valid : (State, SCode.Restriction) => () =
assert_valid(st,re) => fail

end

relation is_function: State => () =
axiom is_function FUNCTION(_) => ()
end
4 changes: 3 additions & 1 deletion modeq/dae.rml
Expand Up @@ -144,10 +144,12 @@ relation dump2: DAElist => () =
Exp.print_component_ref cr &
Print.print_buf "=" &
Exp.print_exp e &
Print.print_buf ",dims=" &
Dump.print_list(dims,Exp.print_subscript,", ") &
Print.print_buf ")\n" &
dump2 (DAE(xs))
-------------------
dump2 DAE(VAR(cr,_,_,_,SOME(e),_)::xs)
dump2 DAE(VAR(cr,_,_,_,SOME(e),dims)::xs)

rule Print.print_buf "VAR(" &
Exp.print_component_ref cr &
Expand Down
1 change: 1 addition & 0 deletions modeq/dump.rml
Expand Up @@ -75,6 +75,7 @@ module Dump:
relation unparse_within: (int, Absyn.Within) => string
relation indent_str: (int) => string
relation unparse_algorithm_str: (int, Absyn.AlgorithmItem) => string
relation variability_symbol: Absyn.Variability => string
end


Expand Down
104 changes: 104 additions & 0 deletions modeq/exp.rml
Expand Up @@ -131,6 +131,7 @@ module Exp:
relation int_subscripts : int list => Subscript list
relation simplify : Exp => Exp
relation unelab_exp : Exp => Absyn.Exp
relation contain_functioncall : Exp => bool
relation print_exp : Exp => ()
relation print_component_ref : ComponentRef => ()
relation print_component_ref_str : ComponentRef => string
Expand Down Expand Up @@ -305,6 +306,109 @@ relation simplify : Exp => Exp =
axiom simplify e => e

end
(** relation: contain_functioncall
** Returns true if expression or subexpression is a functioncall.
** otherwise false
**)
relation contain_functioncall : Exp => bool =

axiom contain_functioncall(CALL(_,_,_,_)) => true

(* Binary *)
rule contain_functioncall(e1) => true
---------------------
contain_functioncall(BINARY(e1,_,e2)) => true

rule contain_functioncall(e2) => true
---------------------
contain_functioncall(BINARY(e1,_,e2)) => true

(* Unary *)
rule contain_functioncall(e) => res
---------------------
contain_functioncall(UNARY(_,e)) => res

(* LBinary *)
rule contain_functioncall(e1) => true
---------------------
contain_functioncall(LBINARY(e1,_,e2)) => true

rule contain_functioncall(e2) => true
---------------------
contain_functioncall(LBINARY(e1,_,e2)) => true

(* LUnary *)
rule contain_functioncall(e) => res
---------------------
contain_functioncall(LUNARY(_,e)) => res

(* Relation *)
rule contain_functioncall(e1) => true
---------------------
contain_functioncall(RELATION(e1,_,e2)) => true

rule contain_functioncall(e2) => true
---------------------
contain_functioncall(RELATION(e1,_,e2)) => true

(* If exp*)
rule contain_functioncall(e1) => true
--------------------------------
contain_functioncall(IFEXP(e1,e2,e3)) => true

rule contain_functioncall(e2) => true
--------------------------------
contain_functioncall(IFEXP(e1,e2,e3)) => true

rule contain_functioncall(e3) => true
--------------------------------
contain_functioncall(IFEXP(e1,e2,e3)) => true

(* Array *)
rule Util.list_map(elst,contain_functioncall) => blst &
Util.bool_or_list(blst) => res
------------------------------
contain_functioncall(ARRAY(_,_,elst)) => res

(* Matrix *)
rule Util.list_flatten(explst) => flatexplst &
Util.list_map(flatexplst,Util.tuple2_1) => elst &
Util.list_map(elst,contain_functioncall) => blst &
Util.bool_or_list(blst) => res
------------------------------
contain_functioncall(MATRIX(_,_,explst)) => res

(* Range *)
rule contain_functioncall(e1) => true
------------------------------
contain_functioncall(RANGE(_,e1,optexp,e2)) => true

rule contain_functioncall(e2) => true
------------------------------
contain_functioncall(RANGE(_,e1,optexp,e2)) => true

rule contain_functioncall(e) => true
------------------------------
contain_functioncall(RANGE(_,e1,SOME(e),e2)) => true

(* Tuple *)
axiom contain_functioncall(TUPLE(_)) => true

rule contain_functioncall(e) => res
------------------------------
contain_functioncall(CAST(_,e)) => res

(* Size *)
rule contain_functioncall(e1) => true
--------------------------------
contain_functioncall(SIZE(e1,e2)) => true

rule contain_functioncall(e2) => true
--------------------------------
contain_functioncall(SIZE(e1,e2)) => true

axiom contain_functioncall(_) => false
end

relation unelab_exp : Exp => Absyn.Exp =

Expand Down
11 changes: 9 additions & 2 deletions modeq/explode.rml
Expand Up @@ -141,7 +141,7 @@ module SCode :
* Variability (* parameter *)
* Absyn.Direction

datatype Variability = VAR | DISCRETE | PARAM | STRUCTPARAM | CONST
datatype Variability = VAR | DISCRETE | PARAM | STRUCTPARAM | CONST

datatype Accessibility = RW (* read/write *)
| RO (* read-only *)
Expand All @@ -156,6 +156,7 @@ module SCode :
relation print_element : Element => ()
relation print_element_list : Element list => ()
relation print_restr: Restriction => ()
relation variability_string: Variability => string

end

Expand Down Expand Up @@ -823,4 +824,10 @@ relation print_element : Element => () =
print_element(IMPORT(_))
end


relation variability_string: Variability => string =
axiom variability_string(VAR) => "VAR"
axiom variability_string(DISCRETE) => "DISCRETE"
axiom variability_string(PARAM) => "PARAM"
axiom variability_string(STRUCTPARAM) => "STRUCTPARAM"
axiom variability_string(CONST) => "CONST"
end

0 comments on commit 785360c

Please sign in to comment.