Skip to content

Commit

Permalink
Lots of new types.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@190 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
x97davka committed Mar 12, 1998
1 parent 3fb16f3 commit d246490
Showing 1 changed file with 47 additions and 9 deletions.
56 changes: 47 additions & 9 deletions modeq/types.rml
@@ -1,37 +1,49 @@

module Types :

with "explode.rml"
with "exp.rml"

datatype ArrayDim = NODIM
| ONEDIM of Exp.Subscript
| TWODIM of Exp.Subscript * Exp.Subscript

type Ident = string
datatype Type = COMPLEX of (Ident * Type) list
type Var = (Ident * VarAttr * Type)
datatype Type = COMPLEX of Var list
| BUILTIN of string
datatype VarType = VAR | PARAM | CONST
datatype Direction = INPUT | OUTPUT | BIDIR
datatype VarAttr = ATTR of ArrayDim
* bool (* flow *)
* VarType (* parameter *)
* Direction

relation same_type : (Type, Type) => ()
relation lookup_component : (Type, Ident) => Var

end

relation pick : ((Ident * Type) list, Ident) => ((Ident * Type) list, Type) =
relation pick : (Var list, Ident) => (Var list, VarAttr, Type) =

rule n1 = n2
-------
pick((n1,t)::xs,n2) => (xs,t)
pick((n1,attr,t)::xs,n2) => (xs,attr,t)

rule pick(xs,n) => (xs',t)
rule pick(xs,n) => (xs',attr,t)
---------------------
pick(_::xs,n) => (xs',t)
pick(_::xs,n) => (xs',attr,t)

end

relation same_type_c : ((Ident * Type) list, (Ident * Type) list) => () =
relation same_type_c : (Var list, Var list) => () =

axiom same_type_c([], [])

rule pick(xs2,n) => (xs2',t2) &
rule pick(xs2,n) => (xs2',attr,t2) &
same_type(t1,t2) &
same_type_c(xs1,xs2')
---------------------
same_type_c((n,t1)::xs1, xs2)
same_type_c((n,_,t1)::xs1, xs2)

end

Expand All @@ -46,3 +58,29 @@ and same_type : (Type, Type) => () =
same_type(COMPLEX(els1), COMPLEX(els2))

end

relation lookup_component2 : (Var list , Ident) => Var =

rule n = m
-----
lookup_component2((v as (n,_,_))::_, m) => v

rule lookup_component2(vs, n) => v
-----------------------------
lookup_component2(v::vs, n) => v

end

relation lookup_component : (Type, Ident) => Var =

rule print "# trying to lookup in builtin type " & print n & print "\n" &
fail
----
lookup_component(BUILTIN(n),_)
=> (("", ATTR(NODIM,false,VAR,BIDIR), BUILTIN("error")))

rule lookup_component2(cs, id) => v
------------------------------
lookup_component(COMPLEX(cs), id) => v

end

0 comments on commit d246490

Please sign in to comment.