Skip to content

Commit

Permalink
2006-01-24 adrpo@ida
Browse files Browse the repository at this point in the history
- changes to comments only
- moved comments arround so they apper in the generated .mo files




git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2045 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Jan 24, 2006
1 parent e46af10 commit 3659147
Show file tree
Hide file tree
Showing 3 changed files with 363 additions and 192 deletions.
35 changes: 24 additions & 11 deletions Compiler/Algorithm.rml
Expand Up @@ -65,7 +65,7 @@ module Algorithm:

type Ident = string

(** The `Algorithm' type corresponds to a whole algorithm secion. *)
(** The `Algorithm' type corresponds to a whole algorithm section. *)
(** It is simple a list of algorithm statements. *)
datatype Algorithm = ALGORITHM of Statement list

Expand Down Expand Up @@ -258,6 +258,7 @@ relation get_prop_exp_type : Types.Properties => Exp.Type =

end


(** relation: get_type_exp_type
**
** Returns the expression type for a given Type module type. Used only by
Expand All @@ -278,6 +279,7 @@ relation get_type_exp_type : Types.Type => Exp.Type =

end


(** relation: make_if
**
** This relation creates an `IF' construct, checking that the types
Expand All @@ -302,15 +304,17 @@ relation make_if : (Exp.Exp,

end


(** relation: make_else
**
**
**)
relation make_else : ((Exp.Exp * Types.Properties * Statement list) list,
Statement list) => Else =

(** This removes empty else branches *)
axiom make_else ([],[]) => NOELSE

axiom (** This removes empty else branches *)
make_else ([],[]) => NOELSE

axiom make_else ([],fb) => ELSE(fb)

Expand All @@ -327,6 +331,7 @@ relation make_else : ((Exp.Exp * Types.Properties * Statement list) list,

end


(** relation: make_for
**)
relation make_for : (Ident, Exp.Exp, Types.Properties,
Expand All @@ -344,6 +349,7 @@ relation make_for : (Ident, Exp.Exp, Types.Properties,
make_for(_,e,Types.PROP(t,_),_) => fail
end


(** relation: make_while
**)
relation make_while : (Exp.Exp, Types.Properties,
Expand All @@ -359,6 +365,7 @@ relation make_while : (Exp.Exp, Types.Properties,

end


(** relation: make_when_a
**)
relation make_when_a : (Exp.Exp, Types.Properties,
Expand All @@ -376,12 +383,19 @@ relation make_when_a : (Exp.Exp, Types.Properties,
make_when_a(e,Types.PROP(t,_),_) => fail
end


(** relation: make_assert
**
** Creates an assert statenebt from two expressions.
** Creates an assert statement from two expressions.
**
** inputs: (Exp.Exp, /* condition */
Exp.Exp, /* message */
Types.Properties,
Types.Properties)
** outputs: Statement
**)
relation make_assert: (Exp.Exp, (* condition *)
Exp.Exp, (* message *)
relation make_assert: (Exp.Exp,
Exp.Exp,
Types.Properties,
Types.Properties)
=> Statement =
Expand All @@ -400,6 +414,7 @@ relation make_assert: (Exp.Exp, (* condition *)
*)
end


(** relation: get_all_exps
**
** This relation goes through the Algorithm structure and finds all the
Expand All @@ -413,12 +428,12 @@ relation get_all_exps : Algorithm => Exp.Exp list =

end


(** relation: get_all_exps_stmts
**
** This relation takes a list of statements and returns all expressions
** in all statements.
**)

relation get_all_exps_stmts : Statement list => Exp.Exp list=

rule Util.list_map(stmts, get_all_exps_stmt) => expslist &
Expand All @@ -432,7 +447,6 @@ end
**
** Returns all expressions in a statement.
**)

relation get_all_exps_stmt : Statement => Exp.Exp list =

rule cref_to_exp cr => crexp
Expand All @@ -447,7 +461,6 @@ relation get_all_exps_stmt : Statement => Exp.Exp list =
-----------------------
get_all_exps_stmt ASSIGN_ARR(expty, cr, exp) => [crexp,exp]


rule get_all_exps_stmts stmts => exps1 &
get_all_exps_else else => elseexps &
list_append(exps1, elseexps) => exps
Expand All @@ -474,11 +487,11 @@ relation get_all_exps_stmt : Statement => Exp.Exp list =

end


(** relation: get_all_exps_else
**
** Helper relation to get_all_exps_stmt.
**)

relation get_all_exps_else : Else => Exp.Exp list =

axiom get_all_exps_else NOELSE => []
Expand All @@ -495,12 +508,12 @@ relation get_all_exps_else : Else => Exp.Exp list =

end


(** relation: cref_to_exp
**
** Creates an expression from a componentref.
** The type of the expression will become Exp.OTHER.
**)

relation cref_to_exp : Exp.ComponentRef => Exp.Exp =

axiom cref_to_exp cref => Exp.CREF(cref, Exp.OTHER)
Expand Down
42 changes: 19 additions & 23 deletions Compiler/Builtin.rml
Expand Up @@ -65,7 +65,6 @@ module Builtin:
val int_type : SCode.Class
val str_type : SCode.Class
val bool_type : SCode.Class

val real_type : SCode.Class

relation initial_env : () => Env.Env
Expand All @@ -75,7 +74,7 @@ end



(**)
(* protected imports *)
with "Types.rml"
with "ClassInf.rml"
with "Debug.rml"
Expand All @@ -86,7 +85,6 @@ with "Print.rml"
** These are the primitive types that are used to build the types
** `Real', `Integer' etc.
**)

val rl_type = SCode.CLASS("RealType",false,false,SCode.R_PREDEFINED_REAL,
SCode.PARTS([],[],[],[],[],NONE))
val int_type = SCode.CLASS("IntegerType",false,false,SCode.R_PREDEFINED_INT,
Expand Down Expand Up @@ -181,6 +179,8 @@ val boolean_start = SCode.COMPONENT("start",true,false,false,
Absyn.IDENT("BooleanType"),
SCode.MOD(false,Absyn.NON_EACH,[],SOME(Absyn.BOOL(false))),NONE,NONE)


(* Should be true for variables *)
val fixed = SCode.COMPONENT("fixed",true,false,false,
SCode.ATTR([],
false,
Expand All @@ -189,7 +189,7 @@ val fixed = SCode.COMPONENT("fixed",true,false,false,
Absyn.BIDIR),
Absyn.IDENT("BooleanType"),
SCode.MOD(false,Absyn.NON_EACH,[],SOME(Absyn.BOOL(false))),NONE,NONE)
(* Should be true for variables*)


val nominal = SCode.COMPONENT("nominal",true,false,false,
SCode.ATTR([],
Expand Down Expand Up @@ -221,12 +221,12 @@ val state_select_comps =
SCode.COMPONENT("always",true,false,false,SCode.ATTR([],false,SCode.RO,SCode.CONST,Absyn.BIDIR),Absyn.IDENT("EnumType"),SCode.NOMOD,NONE,NONE)
]

(* The State Select Type *)
val state_select_type =
SCode.CLASS("StateSelect",false,false,SCode.R_ENUMERATION,SCode.PARTS(state_select_comps,[],[],[],[],NONE))


(** - The `Real' type *)

val real_type =
SCode.CLASS("Real",false,false,SCode.R_PREDEFINED_REAL,
SCode.PARTS
Expand All @@ -236,8 +236,8 @@ SCode.CLASS("Real",false,false,SCode.R_PREDEFINED_REAL,
[],
[],NONE))

(** - The `Integer' type *)

(** - The `Integer' type *)
val integer_type =
SCode.CLASS("Integer",false,false,SCode.R_PREDEFINED_INT,
SCode.PARTS
Expand All @@ -247,8 +247,8 @@ SCode.CLASS("Integer",false,false,SCode.R_PREDEFINED_INT,
[],
[],NONE))

(** - The `String' type *)

(** - The `String' type *)
val string_type =
SCode.CLASS("String",false,false,SCode.R_PREDEFINED_STRING,
SCode.PARTS
Expand All @@ -258,8 +258,8 @@ SCode.CLASS("String",false,false,SCode.R_PREDEFINED_STRING,
[],
[],NONE))

(** - The `Boolean' type *)

(** - The `Boolean' type *)
val boolean_type =
SCode.CLASS("Boolean",false,false,SCode.R_PREDEFINED_BOOL,
SCode.PARTS
Expand All @@ -269,14 +269,14 @@ SCode.CLASS("Boolean",false,false,SCode.R_PREDEFINED_BOOL,
[],
[],NONE))

(** - The `time' variable *)

(** - The `time' variable *)
val time_var =
Types.VAR("time", Types.ATTR(false, SCode.RO, SCode.VAR, Absyn.BIDIR),
false, (Types.T_REAL([]),NONE), Types.UNBOUND)

(** - Some assorted function types *)

(** - Some assorted function types *)
val nil2real = (Types.T_FUNCTION([],
(Types.T_REAL([]),NONE)),NONE)

Expand Down Expand Up @@ -614,7 +614,7 @@ val array1dimreal2array3dimreal= (Types.T_FUNCTION([("x",(Types.T_ARRAY(Types.DI



(* T_ARRAY is apperantly not constant. To bad! *)
(* T_ARRAY is appearently not constant. To bad! *)
val array2real= (Types.T_FUNCTION([("x",(Types.T_ARRAY(Types.DIM(SOME(1)),(Types.T_INTEGER([]),NONE)),NONE))], (Types.T_INTEGER([]),NONE)),NONE)

(* Legal syntax: val array2one= (Types.T_FUNCTION([("x",(Types.T_ARRAY(1,(Types.T_REAL([]),NONE)),NONE))], TYPES.T_INTEGER) *)
Expand Down Expand Up @@ -677,7 +677,6 @@ val array_array2int


(** - Initial environment *)

(** relation: simple_initial_env
**
** The initial environment where instantiation takes place is built
Expand All @@ -704,25 +703,22 @@ relation simple_initial_env =
simple_initial_env () => env
end


(** relation: initial_env
**
** The initial environment where instantiation takes place is built
** up using this relation. It creates an empty environment and adds
** all the built-in definitions to it.
** NOTE:
The following built in operators can not be described in
the type system, since they e.g. have arbitrary arguments, etc.
- fill
- cat
These operators are catched in the elab_builtin_handler, along with all
others.
**)
relation initial_env =

(* The following built in operators can not be described in
the type system, since they e.g. have arbitrary arguments, etc.

- fill
- cat

These operators are catched in the elab_builtin_handler, along with all
others.
*)


rule (*Debug.fprint ("insttr","Creating initial env.\n") &*)
Env.open_scope(Env.empty_env,false,NONE) => env &
Env.extend_frame_c(env, rl_type) => env &
Expand Down

0 comments on commit 3659147

Please sign in to comment.