2005-08-17 15:45:10 +00:00
|
|
|
(*****************************************************************************
|
2007-07-04 06:41:30 +00:00
|
|
|
* su4sml --- a SML repository for managing (Secure)UML/OCL models
|
|
|
|
* http://projects.brucker.ch/su4sml/
|
2005-08-17 15:45:10 +00:00
|
|
|
*
|
2007-07-04 06:41:30 +00:00
|
|
|
* rep_core.sml --- core repository datastructures for su4sml
|
|
|
|
* This file is part of su4sml.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2005-2007, ETH Zurich, Switzerland
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided
|
|
|
|
* with the distribution.
|
|
|
|
*
|
|
|
|
* * Neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2005-08-17 15:45:10 +00:00
|
|
|
******************************************************************************)
|
2007-07-04 06:41:30 +00:00
|
|
|
(* $Id$ *)
|
2005-08-17 15:45:10 +00:00
|
|
|
|
2006-12-08 17:16:33 +00:00
|
|
|
(** Repository datatypes and helper functions for classifiers. *)
|
2006-04-27 14:27:16 +00:00
|
|
|
signature REP_CORE =
|
|
|
|
sig
|
|
|
|
type Scope
|
|
|
|
type Visibility
|
|
|
|
type operation = { name : string,
|
|
|
|
precondition : (string option * Rep_OclTerm.OclTerm) list,
|
|
|
|
postcondition : (string option * Rep_OclTerm.OclTerm) list,
|
2007-06-07 16:12:25 +00:00
|
|
|
body : (string option * Rep_OclTerm.OclTerm) list,
|
2006-04-27 14:27:16 +00:00
|
|
|
arguments : (string * Rep_OclType.OclType) list,
|
|
|
|
result : Rep_OclType.OclType,
|
|
|
|
isQuery : bool,
|
|
|
|
scope : Scope,
|
|
|
|
visibility : Visibility
|
|
|
|
}
|
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
type associationend = {name : Rep_OclType.Path (* path_of_association @ [aend_name]*),
|
|
|
|
aend_type : Rep_OclType.OclType, (* participant type *)
|
2006-04-27 14:27:16 +00:00
|
|
|
multiplicity: (int * int) list,
|
|
|
|
ordered: bool,
|
|
|
|
visibility: Visibility,
|
|
|
|
init: Rep_OclTerm.OclTerm option
|
|
|
|
}
|
|
|
|
|
|
|
|
type attribute = {
|
|
|
|
name : string,
|
|
|
|
attr_type : Rep_OclType.OclType,
|
|
|
|
visibility : Visibility,
|
|
|
|
scope: Scope,
|
2006-05-03 17:29:43 +00:00
|
|
|
stereotypes: string list,
|
2006-04-27 14:27:16 +00:00
|
|
|
init : Rep_OclTerm.OclTerm option
|
|
|
|
}
|
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
type association = { name: Rep_OclType.Path (* path_of_package @ [assoc_name] *),
|
|
|
|
aends: associationend list,
|
|
|
|
aclass: Rep_OclType.Path option
|
|
|
|
}
|
|
|
|
|
|
|
|
type constraint = (string option * Rep_OclTerm.OclTerm)
|
|
|
|
|
2006-04-27 14:27:16 +00:00
|
|
|
datatype Classifier =
|
|
|
|
Class of
|
2006-12-15 06:52:09 +00:00
|
|
|
{ name : Rep_OclType.OclType,
|
|
|
|
parent : Rep_OclType.OclType option,
|
2006-04-27 14:27:16 +00:00
|
|
|
attributes : attribute list,
|
|
|
|
operations : operation list,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations: Rep_OclType.Path list (* associations *),
|
2006-04-27 14:27:16 +00:00
|
|
|
invariant : (string option * Rep_OclTerm.OclTerm) list,
|
|
|
|
stereotypes : string list,
|
2006-12-15 06:52:09 +00:00
|
|
|
interfaces : Rep_OclType.OclType list,
|
2006-04-27 14:27:16 +00:00
|
|
|
thyname : string option,
|
|
|
|
activity_graphs : Rep_ActivityGraph.ActivityGraph list
|
|
|
|
}
|
2007-09-26 07:55:59 +00:00
|
|
|
| AssociationClass of (* billk_tag *)
|
|
|
|
{ name : Rep_OclType.OclType,
|
|
|
|
parent : Rep_OclType.OclType option,
|
|
|
|
attributes : attribute list,
|
|
|
|
operations : operation list,
|
|
|
|
invariant : (string option * Rep_OclTerm.OclTerm) list,
|
|
|
|
stereotypes : string list,
|
|
|
|
interfaces : Rep_OclType.OclType list,
|
|
|
|
thyname : string option,
|
|
|
|
activity_graphs : Rep_ActivityGraph.ActivityGraph list,
|
|
|
|
(* visibility : Visibility,
|
|
|
|
isActive : bool,
|
|
|
|
generalizations : string list,
|
|
|
|
taggedValue : TaggedValue list,
|
|
|
|
clientDependency : string list,
|
|
|
|
supplierDependency : string list,
|
|
|
|
*) associations: Rep_OclType.Path list,
|
|
|
|
association: Rep_OclType.Path
|
|
|
|
}
|
2006-04-27 14:27:16 +00:00
|
|
|
| Interface of (* not supported yet *)
|
2006-12-15 06:52:09 +00:00
|
|
|
{ name : Rep_OclType.OclType,
|
|
|
|
parents : Rep_OclType.OclType list,
|
2006-04-27 14:27:16 +00:00
|
|
|
operations : operation list,
|
|
|
|
stereotypes : string list,
|
|
|
|
invariant : (string option * Rep_OclTerm.OclTerm) list,
|
|
|
|
thyname : string option
|
|
|
|
}
|
|
|
|
| Enumeration of (* not really supported yet? *)
|
2006-12-15 06:52:09 +00:00
|
|
|
{ name : Rep_OclType.OclType,
|
|
|
|
parent : Rep_OclType.OclType option,
|
2006-04-27 14:27:16 +00:00
|
|
|
operations : operation list,
|
|
|
|
literals : string list,
|
|
|
|
invariant : (string option * Rep_OclTerm.OclTerm) list,
|
|
|
|
stereotypes : string list,
|
2006-12-15 06:52:09 +00:00
|
|
|
interfaces : Rep_OclType.OclType list,
|
2006-04-27 14:27:16 +00:00
|
|
|
thyname : string option
|
|
|
|
}
|
|
|
|
| Primitive of (* not really supported yet *)
|
2006-12-15 06:52:09 +00:00
|
|
|
{ name : Rep_OclType.OclType,
|
|
|
|
parent : Rep_OclType.OclType option,
|
2006-04-27 14:27:16 +00:00
|
|
|
operations : operation list,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations: Rep_OclType.Path list,
|
2006-04-27 14:27:16 +00:00
|
|
|
invariant : (string option * Rep_OclTerm.OclTerm) list,
|
|
|
|
stereotypes : string list,
|
2006-12-15 06:52:09 +00:00
|
|
|
interfaces : Rep_OclType.OclType list,
|
2006-04-27 14:27:16 +00:00
|
|
|
thyname : string option
|
|
|
|
}
|
2006-10-04 08:03:29 +00:00
|
|
|
| Template of
|
|
|
|
{ parameter : Rep_OclType.OclType,
|
|
|
|
classifier : Classifier
|
|
|
|
}
|
2006-04-27 14:27:16 +00:00
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
type transform_model = (Classifier list * association list)
|
|
|
|
|
2006-04-27 14:27:16 +00:00
|
|
|
val OclAnyC : Classifier
|
|
|
|
|
2007-11-27 15:13:44 +00:00
|
|
|
val joinModel : transform_model -> transform_model -> transform_model
|
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
val normalize : association list -> Classifier -> Classifier
|
2006-04-27 14:27:16 +00:00
|
|
|
val normalize_init : Classifier -> Classifier
|
2007-09-26 07:55:59 +00:00
|
|
|
val normalize_ext : transform_model -> transform_model
|
2006-04-27 14:27:16 +00:00
|
|
|
|
|
|
|
val name_of : Classifier -> Rep_OclType.Path
|
2006-12-15 06:52:09 +00:00
|
|
|
val type_of : Classifier -> Rep_OclType.OclType
|
2006-04-27 14:27:16 +00:00
|
|
|
val package_of : Classifier -> Rep_OclType.Path
|
|
|
|
val short_name_of : Classifier -> string
|
|
|
|
|
|
|
|
val parent_name_of : Classifier -> Rep_OclType.Path
|
2007-02-09 11:14:53 +00:00
|
|
|
val parent_interface_names_of : Classifier -> Rep_OclType.Path list
|
2006-04-27 14:27:16 +00:00
|
|
|
val parent_package_of : Classifier -> Rep_OclType.Path
|
|
|
|
val short_parent_name_of : Classifier -> string
|
2007-02-09 11:14:53 +00:00
|
|
|
val parent_interfaces_of : Classifier -> Rep_OclType.OclType list
|
2006-04-27 14:27:16 +00:00
|
|
|
|
|
|
|
val thy_name_of : Classifier -> string
|
|
|
|
val attributes_of : Classifier -> attribute list
|
2007-09-26 07:55:59 +00:00
|
|
|
val associationends_of: association list -> Classifier -> associationend list
|
2007-11-22 21:37:10 +00:00
|
|
|
val associations_of : Classifier -> Rep_OclType.Path list
|
2007-09-26 07:55:59 +00:00
|
|
|
|
2006-04-27 14:27:16 +00:00
|
|
|
val operations_of : Classifier -> operation list
|
|
|
|
val invariant_of : Classifier -> (string option * Rep_OclTerm.OclTerm) list
|
2006-05-03 17:29:43 +00:00
|
|
|
val stereotypes_of : Classifier -> string list
|
2007-11-18 21:10:46 +00:00
|
|
|
val string_of_path : Rep_OclType.Path -> string
|
2007-11-27 15:13:44 +00:00
|
|
|
val short_name_of_path : Rep_OclType.Path -> string
|
2007-02-08 17:02:09 +00:00
|
|
|
val activity_graphs_of: Classifier -> Rep_ActivityGraph.ActivityGraph list
|
2006-04-27 14:27:16 +00:00
|
|
|
|
2006-04-28 08:14:04 +00:00
|
|
|
val arguments_of_op : operation -> (string * Rep_OclType.OclType) list
|
2006-04-27 14:27:16 +00:00
|
|
|
val precondition_of_op : operation -> (string option * Rep_OclTerm.OclTerm) list
|
2007-06-07 16:12:25 +00:00
|
|
|
val body_of_op : operation -> (string option * Rep_OclTerm.OclTerm) list
|
2006-04-28 08:14:04 +00:00
|
|
|
val result_of_op : operation -> Rep_OclType.OclType
|
2006-04-27 14:27:16 +00:00
|
|
|
val postcondition_of_op : operation -> (string option * Rep_OclTerm.OclTerm) list
|
|
|
|
val name_of_op : operation -> string
|
|
|
|
val mangled_name_of_op : operation -> string
|
|
|
|
|
2006-04-28 08:14:04 +00:00
|
|
|
val class_of : Rep_OclType.Path -> Classifier list -> Classifier
|
|
|
|
val parent_of : Classifier -> Classifier list -> Classifier
|
|
|
|
val parents_of : Classifier -> Classifier list -> Rep_OclType.Path list
|
|
|
|
val operation_of : Classifier list -> Rep_OclType.Path -> operation option
|
|
|
|
val topsort_cl : Classifier list -> Classifier list
|
2007-09-26 07:55:59 +00:00
|
|
|
val connected_classifiers_of : association list -> Classifier -> Classifier list -> Classifier list
|
2007-05-27 18:32:37 +00:00
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
(* billk_tag *)
|
|
|
|
(* changed assoc to aend, since associations are now part of the model *)
|
|
|
|
val aend_to_attr_type : associationend -> Rep_OclType.OclType
|
2007-06-05 07:43:03 +00:00
|
|
|
|
2007-06-05 11:40:12 +00:00
|
|
|
val update_thyname : string -> Classifier -> Classifier
|
|
|
|
val update_invariant : (string option * Rep_OclTerm.OclTerm) list -> Classifier -> Classifier
|
|
|
|
val update_operations : operation list -> Classifier -> Classifier
|
|
|
|
|
|
|
|
val update_precondition : (string option * Rep_OclTerm.OclTerm) list -> operation -> operation
|
|
|
|
val update_postcondition : (string option * Rep_OclTerm.OclTerm) list -> operation -> operation
|
2007-06-05 07:43:03 +00:00
|
|
|
|
2007-11-16 16:21:52 +00:00
|
|
|
val addInvariant : constraint -> Classifier -> Classifier
|
|
|
|
val addOperation : operation -> Classifier -> Classifier
|
2007-11-27 22:53:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
exception InvalidArguments of string
|
|
|
|
|
2006-04-27 14:27:16 +00:00
|
|
|
end
|
|
|
|
|
2005-09-07 18:23:24 +00:00
|
|
|
structure Rep_Core : REP_CORE =
|
2005-08-17 15:45:10 +00:00
|
|
|
struct
|
2005-09-14 13:24:57 +00:00
|
|
|
open library
|
2007-01-29 16:14:56 +00:00
|
|
|
open Rep_OclType
|
2005-10-20 13:03:44 +00:00
|
|
|
|
|
|
|
type Visibility = XMI_DataTypes.VisibilityKind
|
|
|
|
type Scope = XMI_DataTypes.ScopeKind
|
|
|
|
|
2005-08-17 15:45:10 +00:00
|
|
|
type operation = { name : string,
|
2005-09-07 18:23:24 +00:00
|
|
|
precondition : (string option * Rep_OclTerm.OclTerm) list,
|
|
|
|
postcondition : (string option * Rep_OclTerm.OclTerm) list,
|
2007-06-07 16:12:25 +00:00
|
|
|
body : (string option * Rep_OclTerm.OclTerm) list,
|
2005-09-07 18:23:24 +00:00
|
|
|
arguments : (string * Rep_OclType.OclType) list,
|
|
|
|
result : Rep_OclType.OclType,
|
2005-10-20 13:03:44 +00:00
|
|
|
isQuery : bool,
|
|
|
|
visibility : Visibility,
|
|
|
|
scope : Scope }
|
2005-08-17 15:45:10 +00:00
|
|
|
|
2005-11-01 07:32:21 +00:00
|
|
|
type associationend = {
|
2007-09-26 07:55:59 +00:00
|
|
|
name : Rep_OclType.Path,
|
2007-02-07 13:32:55 +00:00
|
|
|
aend_type : Rep_OclType.OclType,
|
|
|
|
multiplicity : (int*int) list,
|
|
|
|
visibility : Visibility,
|
|
|
|
ordered : bool,
|
|
|
|
init : Rep_OclTerm.OclTerm option
|
2005-11-01 07:32:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type attribute = {
|
2007-02-07 13:32:55 +00:00
|
|
|
name : string,
|
|
|
|
attr_type : Rep_OclType.OclType,
|
|
|
|
visibility : Visibility,
|
|
|
|
scope : Scope,
|
|
|
|
stereotypes : string list,
|
|
|
|
init : Rep_OclTerm.OclTerm option
|
2005-11-01 07:32:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
type association = { name: Rep_OclType.Path,
|
|
|
|
aends: associationend list,
|
|
|
|
aclass: Rep_OclType.Path option
|
|
|
|
}
|
2005-11-01 07:32:21 +00:00
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
type constraint = (string option * Rep_OclTerm.OclTerm)
|
2005-08-17 15:45:10 +00:00
|
|
|
|
|
|
|
datatype Classifier =
|
|
|
|
Class of
|
2006-12-15 06:52:09 +00:00
|
|
|
{ name : Rep_OclType.OclType,
|
|
|
|
parent : Rep_OclType.OclType option,
|
2005-11-01 07:32:21 +00:00
|
|
|
attributes : attribute list,
|
2005-08-17 15:45:10 +00:00
|
|
|
operations : operation list,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations: Rep_OclType.Path list,
|
2005-09-07 18:23:24 +00:00
|
|
|
invariant : (string option * Rep_OclTerm.OclTerm) list,
|
2005-08-17 15:45:10 +00:00
|
|
|
stereotypes : string list,
|
2006-12-15 06:52:09 +00:00
|
|
|
interfaces : Rep_OclType.OclType list,
|
2005-09-07 17:02:47 +00:00
|
|
|
thyname : string option,
|
2005-09-07 17:44:26 +00:00
|
|
|
activity_graphs : Rep_ActivityGraph.ActivityGraph list
|
2005-08-17 15:45:10 +00:00
|
|
|
}
|
2007-09-26 07:55:59 +00:00
|
|
|
| AssociationClass of (* billk_tag *)
|
|
|
|
{ name : Rep_OclType.OclType,
|
|
|
|
parent : Rep_OclType.OclType option,
|
|
|
|
attributes : attribute list,
|
|
|
|
operations : operation list,
|
|
|
|
invariant : (string option * Rep_OclTerm.OclTerm) list,
|
|
|
|
stereotypes : string list,
|
|
|
|
interfaces : Rep_OclType.OclType list,
|
|
|
|
thyname : string option,
|
|
|
|
activity_graphs : Rep_ActivityGraph.ActivityGraph list,
|
|
|
|
(* visibility : Visibility,
|
|
|
|
isActive : bool,
|
|
|
|
generalizations : string list,
|
|
|
|
taggedValue : TaggedValue list,
|
|
|
|
clientDependency : string list,
|
|
|
|
supplierDependency : string list,
|
|
|
|
*) associations: Rep_OclType.Path list,
|
|
|
|
association: Rep_OclType.Path
|
|
|
|
}
|
2005-08-17 15:45:10 +00:00
|
|
|
| Interface of (* not supported yet *)
|
2006-12-15 06:52:09 +00:00
|
|
|
{ name : Rep_OclType.OclType,
|
|
|
|
parents : Rep_OclType.OclType list,
|
2005-08-17 15:45:10 +00:00
|
|
|
operations : operation list,
|
|
|
|
stereotypes : string list,
|
2005-09-07 18:23:24 +00:00
|
|
|
invariant : (string option * Rep_OclTerm.OclTerm) list,
|
2005-08-17 15:45:10 +00:00
|
|
|
thyname : string option
|
|
|
|
}
|
|
|
|
| Enumeration of (* not really supported yet? *)
|
2006-12-15 06:52:09 +00:00
|
|
|
{ name : Rep_OclType.OclType,
|
|
|
|
parent : Rep_OclType.OclType option,
|
2005-08-17 15:45:10 +00:00
|
|
|
operations : operation list,
|
|
|
|
literals : string list,
|
2005-09-07 18:23:24 +00:00
|
|
|
invariant : (string option * Rep_OclTerm.OclTerm) list,
|
2005-08-17 15:45:10 +00:00
|
|
|
stereotypes : string list,
|
2006-12-15 06:52:09 +00:00
|
|
|
interfaces : Rep_OclType.OclType list,
|
2005-08-17 15:45:10 +00:00
|
|
|
thyname : string option
|
|
|
|
}
|
|
|
|
| Primitive of (* not really supported yet *)
|
2006-12-15 06:52:09 +00:00
|
|
|
{ name : Rep_OclType.OclType,
|
|
|
|
parent : Rep_OclType.OclType option,
|
2005-08-17 15:45:10 +00:00
|
|
|
operations : operation list,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations: Rep_OclType.Path list,
|
2005-09-07 18:23:24 +00:00
|
|
|
invariant : (string option * Rep_OclTerm.OclTerm) list,
|
2005-08-17 15:45:10 +00:00
|
|
|
stereotypes : string list,
|
2006-12-15 06:52:09 +00:00
|
|
|
interfaces : Rep_OclType.OclType list,
|
2005-08-17 15:45:10 +00:00
|
|
|
thyname : string option
|
2006-10-04 08:03:29 +00:00
|
|
|
}
|
|
|
|
| Template of
|
|
|
|
{ parameter : Rep_OclType.OclType,
|
|
|
|
classifier : Classifier
|
|
|
|
}
|
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
type transform_model = (Classifier list * association list)
|
|
|
|
|
2007-11-27 22:53:53 +00:00
|
|
|
exception InvalidArguments of string
|
|
|
|
|
2005-08-17 17:22:10 +00:00
|
|
|
(* convert an association end into the corresponding collection type *)
|
2007-09-26 07:55:59 +00:00
|
|
|
fun aend_to_attr_type ({name,aend_type,multiplicity,ordered,visibility,init}:associationend) =
|
2005-10-24 19:51:49 +00:00
|
|
|
case multiplicity of
|
|
|
|
[(0,1)] => aend_type
|
|
|
|
| [(1,1)] => aend_type
|
|
|
|
| _ =>if ordered then Rep_OclType.Sequence aend_type (* OrderedSet? *)
|
|
|
|
else Rep_OclType.Set aend_type
|
2005-08-17 17:22:10 +00:00
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
|
2005-08-17 17:22:10 +00:00
|
|
|
(* convert an association end into an attribute of the *)
|
|
|
|
(* corresponding collection type *)
|
2007-09-26 07:55:59 +00:00
|
|
|
(* original version
|
2005-11-01 07:32:21 +00:00
|
|
|
fun assoc_to_attr (assoc:associationend) = {name = #name assoc,
|
|
|
|
attr_type = assoc_to_attr_type assoc,
|
|
|
|
visibility = #visibility assoc,
|
|
|
|
scope = XMI.InstanceScope,
|
2006-05-03 17:29:43 +00:00
|
|
|
stereotypes = nil,
|
2005-11-01 07:32:21 +00:00
|
|
|
init = #init assoc}
|
2007-09-26 07:55:59 +00:00
|
|
|
*)
|
|
|
|
|
|
|
|
fun aend_to_attr (cls_name:string) (aend:associationend):attribute =
|
2007-11-22 21:37:10 +00:00
|
|
|
{name = List.last (#name aend),
|
2007-09-26 07:55:59 +00:00
|
|
|
attr_type = aend_to_attr_type aend,
|
|
|
|
visibility = #visibility aend,
|
|
|
|
scope = XMI.InstanceScope,
|
|
|
|
stereotypes = nil,
|
|
|
|
init = #init aend}
|
|
|
|
|
|
|
|
|
2005-08-17 17:22:10 +00:00
|
|
|
(* convert a multiplicity range into an invariant of the form *)
|
|
|
|
(* size > lowerBound and size < upperBound ) *)
|
|
|
|
fun range_to_inv cls_name aend (a,b) =
|
2005-09-07 18:23:24 +00:00
|
|
|
let val cls = Rep_OclType.Classifier cls_name
|
2007-09-26 07:55:59 +00:00
|
|
|
val attr_type = aend_to_attr_type aend
|
|
|
|
val attr_name = cls_name@[List.last (#name aend)]
|
2005-09-07 18:23:24 +00:00
|
|
|
val literal_a = Rep_OclTerm.Literal (Int.toString a, Rep_OclType.Integer)
|
|
|
|
val literal_b = Rep_OclTerm.Literal (Int.toString b, Rep_OclType.Integer)
|
|
|
|
val self = Rep_OclTerm.Variable ("self",cls)
|
|
|
|
val attribute = Rep_OclTerm.AttributeCall (self,cls,attr_name,attr_type)
|
2005-08-17 17:22:10 +00:00
|
|
|
val attribute_size =
|
2005-09-07 18:23:24 +00:00
|
|
|
Rep_OclTerm.OperationCall (attribute,attr_type,
|
2005-08-17 17:22:10 +00:00
|
|
|
["oclLib","Collection","size"],[],
|
2005-09-07 18:23:24 +00:00
|
|
|
Rep_OclType.Integer)
|
2005-08-17 17:22:10 +00:00
|
|
|
val lower_bound =
|
2005-09-07 18:23:24 +00:00
|
|
|
Rep_OclTerm.OperationCall (attribute_size,Rep_OclType.Integer,
|
2005-08-17 17:22:10 +00:00
|
|
|
["oclLib","Real",">="],
|
2005-09-07 18:23:24 +00:00
|
|
|
[(literal_a,Rep_OclType.Integer)],Rep_OclType.Boolean)
|
2005-08-17 17:22:10 +00:00
|
|
|
val upper_bound =
|
2005-09-07 18:23:24 +00:00
|
|
|
Rep_OclTerm.OperationCall (attribute_size,Rep_OclType.Integer,
|
2005-08-17 17:22:10 +00:00
|
|
|
["oclLib","Real","<="],
|
2005-09-07 18:23:24 +00:00
|
|
|
[(literal_b,Rep_OclType.Integer)],Rep_OclType.Boolean)
|
2005-08-17 17:22:10 +00:00
|
|
|
val equal =
|
2005-09-07 18:23:24 +00:00
|
|
|
Rep_OclTerm.OperationCall (attribute_size,Rep_OclType.Integer,
|
2005-08-17 17:22:10 +00:00
|
|
|
["oclLib","OclAny","="],
|
2005-09-07 18:23:24 +00:00
|
|
|
[(literal_a,Rep_OclType.Integer)],Rep_OclType.Boolean)
|
2005-08-17 17:22:10 +00:00
|
|
|
in
|
|
|
|
if a = b then equal
|
|
|
|
else if b = ~1 then lower_bound
|
2005-09-07 18:23:24 +00:00
|
|
|
else Rep_OclTerm.OperationCall (lower_bound,Rep_OclType.Boolean,
|
2005-08-17 17:22:10 +00:00
|
|
|
["oclLib","Boolean","and"],
|
2005-09-07 18:23:24 +00:00
|
|
|
[(upper_bound,Rep_OclType.Boolean)],
|
|
|
|
Rep_OclType.Boolean)
|
2005-08-17 17:22:10 +00:00
|
|
|
end
|
|
|
|
|
2005-11-02 17:59:56 +00:00
|
|
|
|
2007-11-27 15:13:44 +00:00
|
|
|
fun short_name_of_path p = (hd o rev) p
|
2005-11-02 17:59:56 +00:00
|
|
|
|
|
|
|
|
2005-08-17 17:22:10 +00:00
|
|
|
(* calculate the invariants of an association end: *)
|
|
|
|
(* 1. multiplicity constraints *)
|
|
|
|
(* 2. consistency constraints between opposing association ends *)
|
|
|
|
(* i.e., A.b.a->includes(A) *)
|
|
|
|
(* FIXME: 2. is not implemented yet... *)
|
2007-09-26 07:55:59 +00:00
|
|
|
fun aend_to_inv cls_name (aend:associationend) =
|
2007-11-27 15:13:44 +00:00
|
|
|
let val inv_name = ("multconstraint_for_aend_"^(short_name_of_path (#name aend)))
|
2005-10-24 19:51:49 +00:00
|
|
|
val range_constraints = case (#multiplicity aend) of
|
2005-11-01 07:32:21 +00:00
|
|
|
[(0,1)] => []
|
|
|
|
| [(1,1)] => let
|
2007-09-26 07:55:59 +00:00
|
|
|
val attr_name = cls_name@[List.last (#name aend)]
|
|
|
|
val attr_type = aend_to_attr_type aend
|
2005-10-24 19:51:49 +00:00
|
|
|
val cls = Rep_OclType.Classifier cls_name
|
|
|
|
val self = Rep_OclTerm.Variable ("self",cls)
|
|
|
|
val attribute = Rep_OclTerm.AttributeCall (self,cls,attr_name,attr_type)
|
|
|
|
in
|
|
|
|
[Rep_OclTerm.OperationCall (attribute,attr_type,
|
|
|
|
["oclIsDefined"],[],
|
|
|
|
Rep_OclType.Boolean)]
|
|
|
|
end
|
|
|
|
| _ => map (range_to_inv cls_name aend)
|
|
|
|
(#multiplicity aend)
|
2005-08-17 17:22:10 +00:00
|
|
|
fun ocl_or (x,y) =
|
2005-09-07 18:23:24 +00:00
|
|
|
Rep_OclTerm.OperationCall (x,Rep_OclType.Boolean,
|
2005-08-17 17:22:10 +00:00
|
|
|
["oclLib","Boolean","or"],
|
2005-09-07 18:23:24 +00:00
|
|
|
[(y,Rep_OclType.Boolean)],Rep_OclType.Boolean)
|
2005-08-17 17:22:10 +00:00
|
|
|
in if range_constraints = []
|
2005-09-07 18:23:24 +00:00
|
|
|
then (SOME inv_name, Rep_OclTerm.Literal ("true",Rep_OclType.Boolean))
|
2005-08-17 17:22:10 +00:00
|
|
|
else (SOME inv_name, foldr1 ocl_or range_constraints)
|
|
|
|
end
|
2006-12-15 06:52:09 +00:00
|
|
|
|
2007-11-22 21:37:10 +00:00
|
|
|
fun associations_of (Class{name,associations,...}) = associations
|
|
|
|
| associations_of (AssociationClass{name,associations,association,...}) = associations
|
|
|
|
| associations_of (Primitive{name,associations,...}) = associations
|
2006-12-15 06:52:09 +00:00
|
|
|
|
2007-11-18 21:10:46 +00:00
|
|
|
(* find all association ends, excluding of self_type *)
|
|
|
|
fun association_to_associationends (associations:association list) (self_type:OclType) (assoc:Path):associationend list=
|
2007-09-26 07:55:59 +00:00
|
|
|
let
|
2007-11-18 21:10:46 +00:00
|
|
|
val _ = trace function_calls "association_to_associationends\n"
|
2007-11-22 21:37:10 +00:00
|
|
|
val _ = trace function_arguments ("assoc: "^(string_of_path assoc)^"\n")
|
2007-11-27 22:53:53 +00:00
|
|
|
val _ = trace function_arguments "associations in list:\n"
|
|
|
|
val _ = map (trace function_arguments o (fn x => "association path: "^x^"\n") o
|
|
|
|
string_of_path o (fn {name,aends,aclass} => name)) associations
|
|
|
|
val association = List.filter (fn {name,aends,aclass} => name = assoc ) associations
|
|
|
|
val aends = case association of
|
|
|
|
[] => raise InvalidArguments "association_to_associationends: no association found\n"
|
|
|
|
| [{name,aends,aclass}] => aends
|
|
|
|
| _ => raise InvalidArguments "association_to_associationends: more than 1 association found\n"
|
2007-11-22 21:37:10 +00:00
|
|
|
val (aendsFiltered,aendsSelf) = List.partition (fn {aend_type,...} =>
|
|
|
|
aend_type <> self_type) aends
|
|
|
|
val aendsFiltered = if List.length aendsSelf > 1 then aendsFiltered@aendsSelf (* reflexiv *)
|
|
|
|
else aendsFiltered
|
|
|
|
val _ = if (List.length aendsFiltered) >1
|
2007-11-18 21:10:46 +00:00
|
|
|
then
|
|
|
|
print "association_to_associationends: aends found\n"
|
|
|
|
else
|
|
|
|
print "association_to_associationends: no aends found\n"
|
2007-09-26 07:55:59 +00:00
|
|
|
in
|
2007-11-22 21:37:10 +00:00
|
|
|
aendsFiltered
|
2007-09-26 07:55:59 +00:00
|
|
|
end
|
2006-12-15 06:52:09 +00:00
|
|
|
|
2007-11-18 21:10:46 +00:00
|
|
|
(** find the associationends belonging to a classifier.
|
|
|
|
* This mean all other associationends from all associations the
|
2007-11-22 21:37:10 +00:00
|
|
|
* classifer is part of. For association classes, the belonging
|
|
|
|
* association also needs to be checked.
|
|
|
|
* If the association is reflexiv, all aends will be returned.
|
2007-11-18 21:10:46 +00:00
|
|
|
*)
|
|
|
|
fun associationends_of (all_associations:association list) (Class{name,associations,...}):associationend list =
|
|
|
|
List.concat (map (association_to_associationends all_associations name) associations)
|
|
|
|
| associationends_of all_associations (AssociationClass{name,associations,association,...}) =
|
|
|
|
(* association only contains endpoints to the other, pure classes *)
|
2007-11-27 22:53:53 +00:00
|
|
|
let
|
|
|
|
val assocs = if List.exists (fn x => x = association ) associations then
|
|
|
|
associations
|
|
|
|
else
|
|
|
|
association::associations
|
|
|
|
in
|
|
|
|
List.concat (map (association_to_associationends all_associations name) assocs)
|
|
|
|
end
|
2007-11-18 21:10:46 +00:00
|
|
|
| associationends_of all_associations (Primitive{name,associations,...}) =
|
|
|
|
List.concat (map (association_to_associationends all_associations name) associations)
|
2007-09-26 07:55:59 +00:00
|
|
|
| associationends_of _ _ = error ("in associationends_of: This classifier has no associationends") (*FIXME: or rather []? *)
|
2006-12-15 06:52:09 +00:00
|
|
|
|
|
|
|
|
2007-11-22 21:37:10 +00:00
|
|
|
(** convert association ends into attributes + invariants
|
|
|
|
* Associations belonging to an association class have not been modified to
|
|
|
|
* include an additional aend to the association class.
|
|
|
|
*)
|
2007-09-26 07:55:59 +00:00
|
|
|
fun normalize (all_associations:association list) (C as (Class {name,parent,attributes,operations,associations,invariant,
|
2007-11-22 21:37:10 +00:00
|
|
|
stereotypes,interfaces,thyname,activity_graphs})):Classifier =
|
|
|
|
let
|
|
|
|
val _ = trace function_calls "normalize: class\n"
|
|
|
|
val _ = trace function_arguments ("number of associations: " ^ (Int.toString (List.length associations )) ^ "\n")
|
2007-11-27 22:53:53 +00:00
|
|
|
val _ = map (trace function_arguments o (fn x => "association path: "^x^"\n") o string_of_path) associations
|
2007-11-22 21:37:10 +00:00
|
|
|
in
|
|
|
|
Class {name = name,
|
|
|
|
parent = parent (*,
|
|
|
|
attributes = (append (map (aend_to_attr (string_of_path (path_of_OclType name)))
|
|
|
|
(associationends_of all_associations C)) attributes)*),
|
|
|
|
attributes = (append (map (aend_to_attr (List.last (path_of_OclType name)))
|
|
|
|
(associationends_of all_associations C)) attributes),
|
|
|
|
operations = operations,
|
|
|
|
associations = nil,
|
|
|
|
invariant = append (map (aend_to_inv (path_of_OclType name)) (associationends_of all_associations C))
|
|
|
|
invariant,
|
|
|
|
stereotypes = stereotypes,
|
|
|
|
interfaces = interfaces,
|
|
|
|
thyname = thyname,
|
|
|
|
activity_graphs = activity_graphs}
|
|
|
|
end
|
2007-09-26 07:55:59 +00:00
|
|
|
| normalize all_associations (AC as (AssociationClass {name,parent,attributes,association,associations,operations,invariant,
|
2007-11-22 21:37:10 +00:00
|
|
|
stereotypes,interfaces,thyname,activity_graphs})) =
|
2007-09-26 07:55:59 +00:00
|
|
|
(* FIXME: how to handle AssociationClass.association? *)
|
2007-11-22 21:37:10 +00:00
|
|
|
let
|
|
|
|
val _ = trace function_calls "normalize: associationclass\n"
|
|
|
|
val _ = trace function_arguments ("number of associations: " ^ (Int.toString (List.length associations )) ^ "\n")
|
|
|
|
in
|
|
|
|
AssociationClass {name = name,
|
|
|
|
parent = parent,
|
|
|
|
attributes = append (map (aend_to_attr (List.last (path_of_OclType name)))
|
|
|
|
(associationends_of all_associations AC)) attributes,
|
|
|
|
operations = operations,
|
|
|
|
invariant = append (map (aend_to_inv (path_of_OclType name)) (associationends_of all_associations AC))
|
|
|
|
invariant,
|
|
|
|
stereotypes = stereotypes,
|
|
|
|
interfaces = interfaces,
|
|
|
|
thyname = thyname,
|
|
|
|
activity_graphs = activity_graphs,
|
|
|
|
associations = [],
|
|
|
|
association = [] (* FIXME? *)}
|
|
|
|
end
|
2007-09-26 07:55:59 +00:00
|
|
|
| normalize all_associations (Primitive p) =
|
2005-08-17 17:22:10 +00:00
|
|
|
(* Primitive's do not have attributes, so we have to convert *)
|
|
|
|
(* them into Classes... *)
|
2007-09-26 07:55:59 +00:00
|
|
|
if (#associations p) = []
|
2005-08-17 17:22:10 +00:00
|
|
|
then Primitive p
|
2007-09-26 07:55:59 +00:00
|
|
|
else normalize all_associations (Class {name = #name p, parent = #parent p, attributes=[],
|
2007-11-22 21:37:10 +00:00
|
|
|
operations = #operations p, invariant = #invariant p,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations = #associations p,
|
2007-11-22 21:37:10 +00:00
|
|
|
stereotypes = #stereotypes p,
|
|
|
|
interfaces = #interfaces p,
|
|
|
|
thyname = #thyname p,
|
|
|
|
activity_graphs=nil})
|
2007-09-26 07:55:59 +00:00
|
|
|
| normalize all_associations c = c
|
2007-11-22 21:37:10 +00:00
|
|
|
|
|
|
|
|
2005-11-02 17:59:56 +00:00
|
|
|
fun rm_init_attr (attr:attribute) = {
|
|
|
|
name = #name attr,
|
|
|
|
attr_type = #attr_type attr,
|
|
|
|
visibility = #visibility attr,
|
|
|
|
scope = #scope attr,
|
2006-05-03 17:29:43 +00:00
|
|
|
stereotypes = #stereotypes attr,
|
2005-11-02 17:59:56 +00:00
|
|
|
init = NONE
|
|
|
|
}:attribute
|
|
|
|
|
|
|
|
|
2007-11-27 15:13:44 +00:00
|
|
|
fun joinModel ((a_cl,a_assoc):transform_model)
|
|
|
|
((b_cl,b_assoc):transform_model)
|
|
|
|
= (a_cl@b_cl,a_assoc@b_assoc)
|
|
|
|
|
2005-11-02 17:59:56 +00:00
|
|
|
fun init_to_inv cls_name (attr:attribute) =
|
|
|
|
case (#init attr) of
|
|
|
|
NONE => (SOME ("init_"^(#name attr)),
|
|
|
|
Rep_OclTerm.Literal ("true",Rep_OclType.Boolean))
|
|
|
|
| SOME(init) => let
|
|
|
|
val attr_name = cls_name@[#name attr]
|
|
|
|
val attr_type = #attr_type attr
|
|
|
|
val cls = Rep_OclType.Classifier cls_name
|
|
|
|
val self = Rep_OclTerm.Variable ("self",cls)
|
|
|
|
val attribute = Rep_OclTerm.AttributeCall (self,cls,attr_name,attr_type)
|
|
|
|
in
|
|
|
|
(SOME ("init_"^(#name attr)),
|
|
|
|
Rep_OclTerm.OperationCall
|
|
|
|
(Rep_OclTerm.OperationCall
|
|
|
|
(self,cls,
|
|
|
|
["oclLib","OclAny","oclIsNew"],[],Rep_OclType.Boolean),Rep_OclType.Boolean,
|
|
|
|
["oclLib","Boolean","implies"],
|
|
|
|
[(Rep_OclTerm.OperationCall (attribute,
|
|
|
|
attr_type,["oclLib","OclAny","="],
|
|
|
|
[(init,attr_type)],Rep_OclType.Boolean),Rep_OclType.Boolean)],
|
|
|
|
Rep_OclType.Boolean)
|
|
|
|
)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
fun normalize_init (Class {name,parent,attributes,operations,associations,invariant,
|
2005-11-02 17:59:56 +00:00
|
|
|
stereotypes,interfaces,thyname,activity_graphs}) =
|
|
|
|
Class {name = name,
|
|
|
|
parent = parent,
|
|
|
|
attributes = (map rm_init_attr attributes),
|
|
|
|
operations = operations,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations = nil,
|
2006-12-15 06:52:09 +00:00
|
|
|
invariant = append (map (init_to_inv (path_of_OclType name)) attributes)
|
2005-11-02 17:59:56 +00:00
|
|
|
invariant,
|
|
|
|
stereotypes = stereotypes,
|
|
|
|
interfaces = interfaces,
|
|
|
|
thyname = thyname,
|
|
|
|
activity_graphs=activity_graphs}
|
2007-09-26 07:55:59 +00:00
|
|
|
| normalize_init (AssociationClass {name,parent,attributes,operations,associations,association,
|
|
|
|
invariant,stereotypes,interfaces,thyname,activity_graphs}) =
|
|
|
|
AssociationClass {name = name,
|
|
|
|
parent = parent,
|
|
|
|
attributes = (map rm_init_attr attributes),
|
|
|
|
operations = operations,
|
|
|
|
associations = nil,
|
|
|
|
association = []:Path (* FIXME: better dummy? *),
|
|
|
|
invariant = append (map (init_to_inv (path_of_OclType name)) attributes)
|
|
|
|
invariant,
|
|
|
|
stereotypes = stereotypes,
|
|
|
|
interfaces = interfaces,
|
|
|
|
thyname = thyname,
|
|
|
|
activity_graphs=activity_graphs}
|
2005-11-02 17:59:56 +00:00
|
|
|
| normalize_init c = c
|
|
|
|
|
2007-11-22 21:37:10 +00:00
|
|
|
fun normalize_ext ((classifiers,associations):transform_model):transform_model =
|
|
|
|
(map (normalize associations) classifiers, associations)
|
2005-11-02 17:59:56 +00:00
|
|
|
|
2006-12-15 06:52:09 +00:00
|
|
|
val OclAnyC = Class{name=Rep_OclType.OclAny,parent=NONE,attributes=[],
|
2005-08-17 15:45:10 +00:00
|
|
|
operations=[], interfaces=[],
|
2007-09-26 07:55:59 +00:00
|
|
|
invariant=[],stereotypes=[], associations=[],
|
2005-09-07 17:02:47 +00:00
|
|
|
thyname=NONE,
|
|
|
|
activity_graphs=nil}
|
2005-08-17 15:45:10 +00:00
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
val OclAnyAC = AssociationClass{name=Rep_OclType.OclAny,parent=NONE,attributes=[],
|
|
|
|
operations=[], interfaces=[],
|
|
|
|
invariant=[],stereotypes=[], associations=[],
|
|
|
|
association= []:Path (* FIXME: sensible dummy *),
|
|
|
|
thyname=NONE,
|
|
|
|
activity_graphs=nil}
|
|
|
|
|
2005-08-17 17:22:10 +00:00
|
|
|
|
2005-09-07 18:23:24 +00:00
|
|
|
fun string_of_path (path:Rep_OclType.Path) = case path of
|
2005-08-17 15:45:10 +00:00
|
|
|
[] => ""
|
|
|
|
| p => foldr1 (fn (a,b) => a^"."^b) p
|
|
|
|
|
2007-06-05 07:43:03 +00:00
|
|
|
|
2005-08-17 15:45:10 +00:00
|
|
|
|
|
|
|
|
2005-09-07 17:02:47 +00:00
|
|
|
fun update_thyname tname (Class{name,parent,attributes,operations,invariant,
|
2007-09-26 07:55:59 +00:00
|
|
|
stereotypes,interfaces,associations,activity_graphs,...})
|
2007-02-05 17:44:37 +00:00
|
|
|
= Class{name=name,parent=parent,attributes=attributes,operations=operations,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations=associations,invariant=invariant,stereotypes=stereotypes,
|
2007-02-05 17:44:37 +00:00
|
|
|
interfaces=interfaces,thyname=(SOME tname),activity_graphs=activity_graphs }
|
2007-09-26 07:55:59 +00:00
|
|
|
| update_thyname tname (AssociationClass{name,parent,attributes,operations,invariant,stereotypes,
|
|
|
|
interfaces,associations,association,activity_graphs,...})
|
|
|
|
= AssociationClass{name=name,parent=parent,attributes=attributes,operations=operations,
|
|
|
|
associations=associations,association=association,invariant=invariant,stereotypes=stereotypes,
|
|
|
|
interfaces=interfaces,thyname=(SOME tname),activity_graphs=activity_graphs }
|
2005-08-17 15:45:10 +00:00
|
|
|
| update_thyname tname (Interface{name,parents,operations,stereotypes,invariant,...})
|
2005-09-07 17:02:47 +00:00
|
|
|
= Interface{name=name,parents=parents,operations=operations,stereotypes=stereotypes,
|
|
|
|
invariant=invariant,thyname=(SOME tname)}
|
|
|
|
| update_thyname tname (Enumeration{name,parent,operations,literals,invariant,
|
|
|
|
stereotypes,interfaces,...})
|
|
|
|
= Enumeration{name=name,parent=parent,operations=operations,literals=literals,
|
|
|
|
invariant=invariant,stereotypes=stereotypes,interfaces=interfaces,
|
|
|
|
thyname=(SOME tname)}
|
2007-09-26 07:55:59 +00:00
|
|
|
| update_thyname tname (Primitive{name,parent,operations,associations,invariant,
|
2005-09-07 17:02:47 +00:00
|
|
|
stereotypes,interfaces,...})
|
|
|
|
= Primitive{name=name,parent=parent,operations=operations,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations=associations,invariant=invariant,
|
2005-09-07 17:02:47 +00:00
|
|
|
stereotypes=stereotypes,interfaces=interfaces,thyname=(SOME tname)}
|
2007-09-26 07:55:59 +00:00
|
|
|
| update_thyname _ (Template T) = error ("in update_thyname: Template does not have a theory")
|
2007-06-05 07:43:03 +00:00
|
|
|
|
|
|
|
fun update_invariant invariant' (Class{name,parent,attributes,operations,invariant,
|
2007-09-26 07:55:59 +00:00
|
|
|
stereotypes,interfaces,associations,activity_graphs,thyname})
|
2007-06-05 07:43:03 +00:00
|
|
|
= Class{name=name,parent=parent,attributes=attributes,operations=operations,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations=associations,invariant=invariant',stereotypes=stereotypes,
|
2007-06-05 07:43:03 +00:00
|
|
|
interfaces=interfaces,thyname=thyname,activity_graphs=activity_graphs }
|
2007-09-26 07:55:59 +00:00
|
|
|
| update_invariant invariant' (AssociationClass{name,parent,attributes,operations,invariant,stereotypes,
|
|
|
|
interfaces,association,associations,activity_graphs,thyname})
|
|
|
|
= AssociationClass{name=name,parent=parent,attributes=attributes,operations=operations,
|
|
|
|
associations=associations,association=association,invariant=invariant',
|
|
|
|
stereotypes=stereotypes,interfaces=interfaces,thyname=thyname,activity_graphs=activity_graphs }
|
2007-06-05 07:43:03 +00:00
|
|
|
| update_invariant invariant' (Interface{name,parents,operations,stereotypes,invariant,thyname})
|
|
|
|
= Interface{name=name,parents=parents,operations=operations,stereotypes=stereotypes,
|
|
|
|
invariant=invariant',thyname=thyname}
|
|
|
|
| update_invariant invariant' (Enumeration{name,parent,operations,literals,invariant,
|
|
|
|
stereotypes,interfaces,thyname})
|
|
|
|
= Enumeration{name=name,parent=parent,operations=operations,literals=literals,
|
|
|
|
invariant=invariant',stereotypes=stereotypes,interfaces=interfaces,
|
|
|
|
thyname=thyname}
|
2007-09-26 07:55:59 +00:00
|
|
|
| update_invariant invariant' (Primitive{name,parent,operations,associations,invariant,
|
2007-06-05 07:43:03 +00:00
|
|
|
stereotypes,interfaces,thyname})
|
|
|
|
= Primitive{name=name,parent=parent,operations=operations,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations=associations,invariant=invariant',
|
2007-06-05 07:43:03 +00:00
|
|
|
stereotypes=stereotypes,interfaces=interfaces,thyname=thyname}
|
2007-09-26 07:55:59 +00:00
|
|
|
| update_invariant _ (Template T) = error ("in update_invariant: Template does not have an invariant")
|
2007-06-05 11:40:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
fun update_operations operations' (Class{name,parent,attributes,invariant,operations,
|
2007-09-26 07:55:59 +00:00
|
|
|
stereotypes,interfaces,associations,activity_graphs,thyname})
|
2007-06-05 11:40:12 +00:00
|
|
|
= Class{name=name,parent=parent,attributes=attributes,invariant=invariant,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations=associations,operations=operations',stereotypes=stereotypes,
|
2007-06-05 11:40:12 +00:00
|
|
|
interfaces=interfaces,thyname=thyname,activity_graphs=activity_graphs }
|
2007-09-26 07:55:59 +00:00
|
|
|
| update_operations operations' (AssociationClass{name,parent,attributes,invariant,operations,stereotypes,
|
|
|
|
interfaces,associations,association,activity_graphs,thyname})
|
|
|
|
= AssociationClass{name=name,parent=parent,attributes=attributes,invariant=invariant,
|
|
|
|
associations=associations,association=association,operations=operations',stereotypes=stereotypes,
|
|
|
|
interfaces=interfaces,thyname=thyname,activity_graphs=activity_graphs }
|
2007-06-05 11:40:12 +00:00
|
|
|
| update_operations operations' (Interface{name,parents,invariant,stereotypes,operations,thyname})
|
|
|
|
= Interface{name=name,parents=parents,invariant=invariant,stereotypes=stereotypes,
|
|
|
|
operations=operations',thyname=thyname}
|
|
|
|
| update_operations operations' (Enumeration{name,parent,invariant,literals,operations,
|
|
|
|
stereotypes,interfaces,thyname})
|
|
|
|
= Enumeration{name=name,parent=parent,invariant=invariant,literals=literals,
|
|
|
|
operations=operations',stereotypes=stereotypes,interfaces=interfaces,
|
|
|
|
thyname=thyname}
|
2007-09-26 07:55:59 +00:00
|
|
|
| update_operations operations' (Primitive{name,parent,invariant,associations,operations,
|
2007-06-05 11:40:12 +00:00
|
|
|
stereotypes,interfaces,thyname})
|
|
|
|
= Primitive{name=name,parent=parent,invariant=invariant,
|
2007-09-26 07:55:59 +00:00
|
|
|
associations=associations,operations=operations',
|
2007-06-05 11:40:12 +00:00
|
|
|
stereotypes=stereotypes,interfaces=interfaces,thyname=thyname}
|
2007-09-26 07:55:59 +00:00
|
|
|
| update_operations _ (Template T) = error ("in update_operations: Template does not have operations")
|
2007-06-05 07:43:03 +00:00
|
|
|
|
2007-02-05 17:44:37 +00:00
|
|
|
|
2007-06-07 16:12:25 +00:00
|
|
|
fun update_precondition pre' ({name,precondition,postcondition,body,arguments,result,isQuery,scope,visibility}:operation)
|
2007-06-05 11:40:12 +00:00
|
|
|
= ({name=name,precondition=pre',postcondition=postcondition,
|
2007-06-07 16:12:25 +00:00
|
|
|
arguments=arguments,body=body,result=result,isQuery=isQuery,scope=scope,
|
2007-06-05 11:40:12 +00:00
|
|
|
visibility=visibility}:operation)
|
|
|
|
|
2007-06-07 16:12:25 +00:00
|
|
|
fun update_postcondition post' ({name,precondition,postcondition,body,arguments,result,isQuery,scope,visibility}:operation)
|
2007-06-05 11:40:12 +00:00
|
|
|
= ({name=name,precondition=precondition,postcondition=post',
|
2007-06-07 16:12:25 +00:00
|
|
|
arguments=arguments,body=body,result=result,isQuery=isQuery,scope=scope,
|
2007-06-05 11:40:12 +00:00
|
|
|
visibility=visibility}:operation)
|
|
|
|
|
2007-02-05 17:44:37 +00:00
|
|
|
|
|
|
|
|
2006-12-15 06:52:09 +00:00
|
|
|
fun type_of (Class{name,...}) = name
|
2007-09-26 07:55:59 +00:00
|
|
|
| type_of (AssociationClass{name,...}) = name
|
2006-12-15 06:52:09 +00:00
|
|
|
| type_of (Interface{name,...}) = name
|
|
|
|
| type_of (Enumeration{name,...}) = name
|
2007-02-05 17:44:37 +00:00
|
|
|
| type_of (Primitive{name,...}) = name
|
2006-12-15 06:52:09 +00:00
|
|
|
| type_of (Template{classifier,...}) = type_of classifier
|
|
|
|
|
|
|
|
|
|
|
|
fun name_of (Class{name,...}) = path_of_OclType name
|
2007-09-26 07:55:59 +00:00
|
|
|
| name_of (AssociationClass{name,...}) = path_of_OclType name
|
2006-12-15 06:52:09 +00:00
|
|
|
| name_of (Interface{name,...}) = path_of_OclType name
|
|
|
|
| name_of (Enumeration{name,...}) = path_of_OclType name
|
2007-02-05 17:44:37 +00:00
|
|
|
| name_of (Primitive{name,...}) = path_of_OclType name
|
2007-04-03 10:40:02 +00:00
|
|
|
| name_of (Template{classifier,...}) = name_of classifier
|
2006-12-15 06:52:09 +00:00
|
|
|
|
2007-11-27 15:13:44 +00:00
|
|
|
|
2006-12-15 06:52:09 +00:00
|
|
|
fun short_name_of C = case (name_of C) of
|
2007-02-05 17:44:37 +00:00
|
|
|
[] => error "in Rep.short_name_of: empty type"
|
2006-12-15 06:52:09 +00:00
|
|
|
| p => (hd o rev) p
|
2005-08-17 15:45:10 +00:00
|
|
|
|
2006-05-03 17:29:43 +00:00
|
|
|
fun stereotypes_of (Class{stereotypes,...}) = stereotypes
|
2007-09-26 07:55:59 +00:00
|
|
|
| stereotypes_of (AssociationClass{stereotypes,...}) = stereotypes
|
2006-05-03 17:29:43 +00:00
|
|
|
| stereotypes_of (Interface{stereotypes,...}) = stereotypes
|
|
|
|
| stereotypes_of (Enumeration{stereotypes,...}) = stereotypes
|
|
|
|
| stereotypes_of (Primitive{stereotypes,...}) = stereotypes
|
2007-02-05 17:44:37 +00:00
|
|
|
| stereotypes_of (Template _) = error "in Rep.stereotypes_of: \
|
|
|
|
\unsupported argument type Template"
|
2006-05-03 17:29:43 +00:00
|
|
|
|
|
|
|
|
2005-08-17 15:45:10 +00:00
|
|
|
|
2006-12-15 06:52:09 +00:00
|
|
|
fun package_of (Class{name,...}) = if (length (path_of_OclType name)) > 1
|
2007-02-05 17:44:37 +00:00
|
|
|
then take (((length (path_of_OclType name)) -1),
|
|
|
|
(path_of_OclType name))
|
2005-09-07 17:02:47 +00:00
|
|
|
else []
|
2007-09-26 07:55:59 +00:00
|
|
|
| package_of (AssociationClass{name,...}) = if (length (path_of_OclType name)) > 1
|
|
|
|
then take (((length (path_of_OclType name)) -1),
|
|
|
|
(path_of_OclType name))
|
|
|
|
else []
|
2006-12-15 06:52:09 +00:00
|
|
|
| package_of (Interface{name,...}) = if (length (path_of_OclType name)) > 1
|
2007-02-05 17:44:37 +00:00
|
|
|
then take (((length (path_of_OclType name)) -1),
|
|
|
|
(path_of_OclType name))
|
2005-09-07 17:02:47 +00:00
|
|
|
else []
|
2006-12-15 06:52:09 +00:00
|
|
|
| package_of (Enumeration{name,...}) = if (length (path_of_OclType name)) > 1
|
2007-02-05 17:44:37 +00:00
|
|
|
then take (((length (path_of_OclType name)) -1),
|
|
|
|
(path_of_OclType name))
|
2005-09-07 17:02:47 +00:00
|
|
|
else []
|
2006-12-15 06:52:09 +00:00
|
|
|
| package_of (Primitive{name,...}) = if (length (path_of_OclType name)) > 1
|
2007-02-05 17:44:37 +00:00
|
|
|
then take (((length (path_of_OclType name)) -1),
|
|
|
|
(path_of_OclType name))
|
2005-09-07 17:02:47 +00:00
|
|
|
else []
|
2006-12-05 12:00:50 +00:00
|
|
|
| package_of (Template{classifier,...}) = package_of classifier
|
2005-09-07 17:02:47 +00:00
|
|
|
|
|
|
|
fun parent_name_of (C as Class{parent,...}) =
|
|
|
|
(case parent of NONE => name_of OclAnyC
|
2007-02-05 17:44:37 +00:00
|
|
|
| SOME p => path_of_OclType p )
|
2007-09-26 07:55:59 +00:00
|
|
|
| parent_name_of (AC as AssociationClass{parent,...}) =
|
|
|
|
(case parent of NONE => name_of OclAnyAC
|
|
|
|
| SOME p => path_of_OclType p )
|
2007-02-05 17:44:37 +00:00
|
|
|
| parent_name_of (Interface{...}) = error "in Rep.parent_name_of: \
|
|
|
|
\unsupported argument type Interface"
|
2005-09-07 17:02:47 +00:00
|
|
|
| parent_name_of (E as Enumeration{parent,...}) =
|
2007-02-05 17:44:37 +00:00
|
|
|
(case parent of NONE => error ("in Rep.parent_name_of: Enumeration "^
|
|
|
|
((string_of_path o name_of) E)
|
2005-09-07 17:02:47 +00:00
|
|
|
^" has no parent")
|
2006-12-15 06:52:09 +00:00
|
|
|
| SOME p => path_of_OclType p )
|
2005-09-07 17:02:47 +00:00
|
|
|
| parent_name_of (D as Primitive{parent,...}) =
|
|
|
|
(case parent of NONE => name_of OclAnyC
|
2007-02-05 17:44:37 +00:00
|
|
|
(* error ("Primitive "^((string_of_path o name_of) D)^" has no parent") *)
|
2006-12-15 06:52:09 +00:00
|
|
|
| SOME p => path_of_OclType p )
|
2007-02-05 17:44:37 +00:00
|
|
|
| parent_name_of (Template _) = error "in Rep.parent_name_of: \
|
|
|
|
\unsupported argument type Template"
|
|
|
|
|
2007-02-09 11:14:53 +00:00
|
|
|
|
2006-12-15 06:52:09 +00:00
|
|
|
fun short_parent_name_of C = case (parent_name_of C) of
|
2007-02-05 17:44:37 +00:00
|
|
|
[] => error "in Rep.short_parent_name_of: empty type"
|
|
|
|
| p => (hd o rev) p
|
|
|
|
|
2005-09-07 17:02:47 +00:00
|
|
|
fun parent_package_of (Class{parent,...}) =
|
|
|
|
(case parent of NONE => package_of OclAnyC
|
2006-12-15 06:52:09 +00:00
|
|
|
| SOME q => let val p = path_of_OclType q in
|
2007-02-05 17:44:37 +00:00
|
|
|
if (length p) > 1
|
|
|
|
then (take (((length p) -1),p))
|
|
|
|
else []
|
|
|
|
end)
|
2007-09-26 07:55:59 +00:00
|
|
|
| parent_package_of (AssociationClass{parent,...}) =
|
|
|
|
(case parent of NONE => package_of OclAnyC
|
|
|
|
| SOME q => let val p = path_of_OclType q in
|
|
|
|
if (length p) > 1
|
|
|
|
then (take (((length p) -1),p))
|
|
|
|
else []
|
|
|
|
end)
|
2005-09-07 17:02:47 +00:00
|
|
|
| parent_package_of (Interface{...}) =
|
2007-02-05 17:44:37 +00:00
|
|
|
error "in Rep.parent_package_of: unsupported argument type Interface"
|
|
|
|
| parent_package_of (E as Enumeration{parent,...}) =
|
|
|
|
(case parent of NONE => error ("in Rep.parent_package_of: Enumeration "^
|
|
|
|
(string_of_path o name_of) E^
|
|
|
|
" has no parent")
|
2006-12-15 06:52:09 +00:00
|
|
|
| SOME q => let val p = path_of_OclType q in
|
|
|
|
if (length p) > 1
|
|
|
|
then (take (((length p) -1),p))
|
|
|
|
else []
|
|
|
|
end )
|
2005-09-07 17:02:47 +00:00
|
|
|
| parent_package_of (Primitive{parent,...}) =
|
|
|
|
(case parent of NONE => package_of OclAnyC
|
|
|
|
(* NONE => error "Primitive has no parent" *)
|
2006-12-15 06:52:09 +00:00
|
|
|
| SOME q => let val p = path_of_OclType q in
|
|
|
|
if (length p) > 1
|
|
|
|
then (take (((length p) -1),p))
|
|
|
|
else []
|
|
|
|
end)
|
2007-02-05 17:44:37 +00:00
|
|
|
| parent_package_of (Template{...}) =
|
|
|
|
error "in Rep.parent_package_of: unsupported argument type Template"
|
2005-08-17 15:45:10 +00:00
|
|
|
|
|
|
|
|
2007-02-09 11:14:53 +00:00
|
|
|
(* Get parent interfaces of a Classifier. *)
|
|
|
|
fun parent_interfaces_of (Interface{parents,...}) = parents
|
|
|
|
| parent_interfaces_of (Class{interfaces,...}) = interfaces
|
2007-09-26 07:55:59 +00:00
|
|
|
| parent_interfaces_of (AssociationClass{interfaces,...}) = interfaces
|
2007-02-09 11:14:53 +00:00
|
|
|
| parent_interfaces_of (Enumeration{interfaces,...}) = interfaces
|
|
|
|
| parent_interfaces_of (Primitive{interfaces,...}) = interfaces
|
|
|
|
| parent_interfaces_of (Template{...}) = error "parent_interfaces_of <Template> not supported"
|
|
|
|
|
|
|
|
(* Get the names of parent interfaces of a Classifier *)
|
|
|
|
fun parent_interface_names_of c = map path_of_OclType (parent_interfaces_of c)
|
|
|
|
|
2005-08-17 15:45:10 +00:00
|
|
|
fun attributes_of (Class{attributes,...}) = attributes
|
2007-09-26 07:55:59 +00:00
|
|
|
| attributes_of (AssociationClass{attributes,...}) = attributes
|
2005-09-07 17:02:47 +00:00
|
|
|
| attributes_of (Interface{...}) =
|
2007-02-05 17:44:37 +00:00
|
|
|
error "in Rep.attributes_of: argument is Interface"
|
2005-09-07 17:02:47 +00:00
|
|
|
| attributes_of (Enumeration{...}) =
|
2007-02-05 17:44:37 +00:00
|
|
|
error "in Rep.attributes_of: argument is Enumeration"
|
2005-09-07 17:02:47 +00:00
|
|
|
| attributes_of (Primitive{...}) = []
|
|
|
|
(* error "attributes_of <Primitive> not supported" *)
|
2006-12-05 12:00:50 +00:00
|
|
|
| attributes_of (Template{parameter,classifier}) = attributes_of classifier
|
2005-08-17 15:45:10 +00:00
|
|
|
|
2007-02-05 17:44:37 +00:00
|
|
|
fun operations_of (Class{operations,...}) = operations
|
2007-09-26 07:55:59 +00:00
|
|
|
| operations_of (AssociationClass{operations,...}) = operations
|
2007-02-05 17:44:37 +00:00
|
|
|
| operations_of (Interface{operations,...}) = operations
|
|
|
|
| operations_of (Enumeration{operations,...}) = operations
|
|
|
|
| operations_of (Primitive{operations,...}) = operations
|
2006-12-05 12:00:50 +00:00
|
|
|
| operations_of (Template{parameter,classifier}) = operations_of classifier
|
2005-08-17 15:45:10 +00:00
|
|
|
|
|
|
|
fun p_invariant_of (Class{invariant,...}) = invariant
|
2007-09-26 07:55:59 +00:00
|
|
|
| p_invariant_of (AssociationClass{invariant,...}) = invariant
|
2005-08-17 15:45:10 +00:00
|
|
|
| p_invariant_of (Interface{invariant,...}) = invariant
|
|
|
|
| p_invariant_of (Enumeration{invariant,...}) = invariant
|
2007-02-05 17:44:37 +00:00
|
|
|
| p_invariant_of (Primitive{invariant,...}) = invariant
|
|
|
|
| p_invariant_of (Template _) = error "in Rep.p_invariant_of: \
|
|
|
|
\unsupported argument type Template"
|
2005-08-17 15:45:10 +00:00
|
|
|
|
|
|
|
fun invariant_of C = case p_invariant_of C of
|
2005-09-07 18:23:24 +00:00
|
|
|
[] => [(NONE, Rep_OclTerm.Literal ("true",Rep_OclType.Boolean))]
|
2005-08-17 15:45:10 +00:00
|
|
|
| il => il
|
|
|
|
|
|
|
|
|
|
|
|
fun precondition_of_op ({precondition,...}:operation) = case precondition of
|
2005-09-07 18:23:24 +00:00
|
|
|
[] => [(NONE, Rep_OclTerm.Literal ("true",Rep_OclType.Boolean))]
|
2005-08-17 15:45:10 +00:00
|
|
|
| il => il
|
|
|
|
|
2007-06-07 16:12:25 +00:00
|
|
|
fun body_of_op ({body,...}:operation) = body
|
2005-08-17 15:45:10 +00:00
|
|
|
|
|
|
|
fun postcondition_of_op ({postcondition, ...}:operation) = case postcondition of
|
2005-09-07 18:23:24 +00:00
|
|
|
[] => [(NONE, Rep_OclTerm.Literal ("true",Rep_OclType.Boolean))]
|
2005-08-17 15:45:10 +00:00
|
|
|
| il => il
|
|
|
|
|
|
|
|
fun name_of_op ({name,...}:operation) = name
|
|
|
|
|
2005-08-24 11:47:57 +00:00
|
|
|
fun mangled_name_of_op ({name,arguments,result,...}:operation) =
|
2005-08-17 15:45:10 +00:00
|
|
|
let
|
2005-09-26 16:20:14 +00:00
|
|
|
val arg_typestrs = map (fn a => (Rep_OclType.string_of_OclType o #2 ) a ) arguments
|
2005-08-17 15:45:10 +00:00
|
|
|
in
|
2005-09-07 17:02:47 +00:00
|
|
|
foldr1 (fn (a,b) =>(a^"_"^b))
|
2005-09-07 18:23:24 +00:00
|
|
|
((name::arg_typestrs)@[Rep_OclType.string_of_OclType result])
|
2005-08-17 15:45:10 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
fun result_of_op ({result,...}:operation) = result
|
|
|
|
|
|
|
|
fun arguments_of_op ({arguments,...}:operation) = arguments
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-09-07 17:02:47 +00:00
|
|
|
fun thy_name_of (C as Class{thyname,...}) =
|
|
|
|
(case thyname of SOME tname => tname
|
|
|
|
| NONE => error ("Class "^((string_of_path o name_of) C)^
|
|
|
|
" has no thyname"))
|
2007-09-26 07:55:59 +00:00
|
|
|
| thy_name_of (AC as AssociationClass{thyname,...}) =
|
|
|
|
(case thyname of SOME tname => tname
|
|
|
|
| NONE => error ("AssociationClass "^((string_of_path o name_of) AC)^
|
|
|
|
" has no thyname"))
|
2005-09-07 17:02:47 +00:00
|
|
|
| thy_name_of (I as Interface{thyname,...}) =
|
|
|
|
(case thyname of SOME tname => tname
|
|
|
|
| NONE => error ("Interface "^((string_of_path o name_of) I)
|
|
|
|
^" has no thyname"))
|
|
|
|
| thy_name_of (E as Enumeration{thyname,...}) =
|
|
|
|
(case thyname of SOME tname => tname
|
|
|
|
| NONE => error ("Enumeration "^((string_of_path o name_of) E)
|
|
|
|
^" has no thyname"))
|
|
|
|
| thy_name_of (P as Primitive{thyname,...}) =
|
|
|
|
(case thyname of SOME tname => tname
|
|
|
|
| NONE => error ("Primitive "^((string_of_path o name_of) P)^
|
|
|
|
" has no thyname"))
|
2007-02-05 17:44:37 +00:00
|
|
|
| thy_name_of (Template _) = error "in Rep.thy_name_of: \
|
|
|
|
\unsupported argument type Template"
|
|
|
|
|
2006-04-28 08:12:27 +00:00
|
|
|
|
2007-11-18 21:10:46 +00:00
|
|
|
fun class_of (name:Path) (cl:Classifier list):Classifier = hd (filter (fn a => if ((name_of a) = name)
|
2006-04-28 08:12:27 +00:00
|
|
|
then true else false ) cl )
|
2007-11-18 21:10:46 +00:00
|
|
|
handle _ => error ("class_of: class "^(string_of_path name)^" not found!\n")
|
2006-04-28 08:12:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
fun parent_of C cl = (class_of (parent_name_of C) cl)
|
|
|
|
|
|
|
|
fun parents_of C cl = case parent_name_of C of
|
|
|
|
[] => []
|
|
|
|
| class => (if( class = (name_of OclAnyC) )
|
|
|
|
then [(name_of OclAnyC)]
|
|
|
|
else [class]@(parents_of (class_of class cl) cl))
|
2007-02-08 17:02:09 +00:00
|
|
|
|
|
|
|
(* returns the activity graphs (list) of the given Classifier --> this is a list of StateMachines*)
|
|
|
|
(* Classifier -> ActivityGraph list *)
|
|
|
|
fun activity_graphs_of (Class{activity_graphs,...}) = activity_graphs
|
|
|
|
| activity_graphs_of _ = []
|
2006-04-28 08:12:27 +00:00
|
|
|
|
|
|
|
fun operation_of cl fq_name =
|
|
|
|
let
|
|
|
|
val classname = (rev o tl o rev) fq_name
|
|
|
|
val operations = operations_of (class_of classname cl)
|
|
|
|
val name = (hd o rev) fq_name
|
|
|
|
in
|
|
|
|
SOME(hd (filter (fn a => if ((name_of_op a) = name)
|
|
|
|
then true else false ) operations ))
|
|
|
|
end
|
|
|
|
|
|
|
|
(* topological sort of class lists *)
|
|
|
|
fun topsort_cl cl =
|
|
|
|
let val OclAny_subcl = filter (fn a => (parent_name_of a) = (name_of OclAnyC)) cl
|
|
|
|
fun subclasses_of cl c = filter (fn a => (parent_name_of a = (name_of c))) cl
|
|
|
|
fun sub [] _ = []
|
|
|
|
| sub cl c = c :: (foldl (op@) [] (map (fn a => sub cl a)
|
|
|
|
(subclasses_of cl c)))
|
|
|
|
in
|
|
|
|
foldl (op@) [] (map (fn a => sub cl a) (OclAny_subcl))
|
|
|
|
end
|
|
|
|
|
2007-09-26 07:55:59 +00:00
|
|
|
fun connected_classifiers_of (all_associations:association list) (C as Class {attributes,associations,...}) (cl:Classifier list) =
|
|
|
|
let val att_classifiers = List.mapPartial (fn (Classifier p) => SOME (class_of p cl)
|
|
|
|
| _ => NONE)
|
|
|
|
(map #attr_type attributes)
|
|
|
|
val aend_classifiers = List.mapPartial (fn (Classifier p) => SOME (class_of p cl)
|
|
|
|
| _ => NONE)
|
|
|
|
(map #aend_type (associationends_of all_associations C))
|
|
|
|
in
|
|
|
|
att_classifiers @ aend_classifiers
|
|
|
|
end
|
|
|
|
| connected_classifiers_of all_associations (AC as AssociationClass {attributes,associations,association,...}) (cl:Classifier list) =
|
2007-02-07 13:32:55 +00:00
|
|
|
let val att_classifiers = List.mapPartial (fn (Classifier p) => SOME (class_of p cl)
|
|
|
|
| _ => NONE)
|
|
|
|
(map #attr_type attributes)
|
2007-09-26 07:55:59 +00:00
|
|
|
(* FIXME: correct handling for association classes? *)
|
2007-02-07 13:32:55 +00:00
|
|
|
val aend_classifiers = List.mapPartial (fn (Classifier p) => SOME (class_of p cl)
|
|
|
|
| _ => NONE)
|
2007-09-26 07:55:59 +00:00
|
|
|
(map #aend_type (associationends_of all_associations AC))
|
2007-02-07 13:32:55 +00:00
|
|
|
in
|
|
|
|
att_classifiers @ aend_classifiers
|
|
|
|
end
|
2007-09-26 07:55:59 +00:00
|
|
|
| connected_classifiers_of all_associations (P as Primitive {associations,...}) (cl:Classifier list) =
|
2007-02-07 13:32:55 +00:00
|
|
|
List.mapPartial (fn (Classifier p) => SOME (class_of p cl)
|
|
|
|
| _ => NONE)
|
2007-09-26 07:55:59 +00:00
|
|
|
(map #aend_type (associationends_of all_associations P))
|
|
|
|
| connected_classifiers_of _ _ _ = nil
|
2007-02-07 13:32:55 +00:00
|
|
|
|
2007-11-16 16:21:52 +00:00
|
|
|
(** adds an invariant to a classifier.
|
|
|
|
*)
|
|
|
|
fun addInvariant inv (Class {name, parent, attributes, operations,
|
|
|
|
associations, invariant, stereotypes,
|
|
|
|
interfaces, thyname, activity_graphs})
|
|
|
|
= Class {name=name, parent=parent, attributes=attributes,
|
|
|
|
operations=operations,
|
|
|
|
associations=associations, invariant=inv::invariant,
|
|
|
|
stereotypes=stereotypes, interfaces=interfaces,
|
|
|
|
thyname=thyname, activity_graphs=activity_graphs}
|
|
|
|
| addInvariant inv (AssociationClass {name, parent, attributes,
|
|
|
|
operations, associations,
|
|
|
|
association, invariant,
|
|
|
|
stereotypes, interfaces,
|
|
|
|
thyname, activity_graphs})
|
|
|
|
= AssociationClass {name=name, parent=parent, attributes=attributes,
|
|
|
|
operations=operations, associations=associations,
|
|
|
|
association=association, invariant=inv::invariant,
|
|
|
|
stereotypes=stereotypes, interfaces=interfaces,
|
|
|
|
thyname=thyname, activity_graphs=activity_graphs}
|
|
|
|
| addInvariant inv (Interface {name, parents, operations,
|
|
|
|
invariant, stereotypes, thyname})
|
|
|
|
= Interface {name=name, parents=parents, operations=operations,
|
|
|
|
invariant=inv::invariant, stereotypes=stereotypes, thyname=thyname}
|
|
|
|
| addInvariant inv (Enumeration {name, parent, operations,
|
|
|
|
literals, invariant, stereotypes,
|
|
|
|
interfaces, thyname})
|
|
|
|
= Enumeration{name=name, parent=parent, operations=operations,literals=literals,
|
|
|
|
invariant=inv::invariant, stereotypes=stereotypes,
|
|
|
|
interfaces=interfaces, thyname=thyname}
|
|
|
|
| addInvariant inv (Primitive {name, parent, operations,
|
|
|
|
associations, invariant,
|
|
|
|
stereotypes, interfaces, thyname})
|
|
|
|
= Primitive{name=name, parent=parent, operations=operations,
|
|
|
|
associations=associations, invariant=inv::invariant,
|
|
|
|
stereotypes=stereotypes, interfaces=interfaces, thyname=thyname}
|
|
|
|
| addInvariant inv (Template {parameter, classifier})
|
|
|
|
= Template { parameter=parameter,
|
|
|
|
classifier=addInvariant inv classifier
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
(** adds an operation to a classifier. *)
|
|
|
|
fun addOperation oper (Class {name, parent, attributes, operations,
|
|
|
|
associations, invariant, stereotypes,
|
|
|
|
interfaces, thyname, activity_graphs})
|
|
|
|
= Class {name=name, parent=parent, attributes=attributes,
|
|
|
|
operations=oper::operations,
|
|
|
|
associations=associations, invariant=invariant,
|
|
|
|
stereotypes=stereotypes, interfaces=interfaces,
|
|
|
|
thyname=thyname, activity_graphs=activity_graphs}
|
|
|
|
| addOperation oper (AssociationClass {name, parent, attributes,
|
|
|
|
operations, associations,
|
|
|
|
association, invariant,
|
|
|
|
stereotypes, interfaces,
|
|
|
|
thyname, activity_graphs})
|
|
|
|
= AssociationClass {name=name, parent=parent, attributes=attributes,
|
|
|
|
operations=oper::operations, associations=associations,
|
|
|
|
association=association, invariant=invariant,
|
|
|
|
stereotypes=stereotypes, interfaces=interfaces,
|
|
|
|
thyname=thyname, activity_graphs=activity_graphs}
|
|
|
|
| addOperation oper (Interface {name, parents, operations,
|
|
|
|
invariant, stereotypes, thyname})
|
|
|
|
= Interface {name=name, parents=parents, operations=oper::operations,
|
|
|
|
invariant=invariant, stereotypes=stereotypes, thyname=thyname}
|
|
|
|
| addOperation oper (Enumeration {name, parent, operations,
|
|
|
|
literals, invariant, stereotypes,
|
|
|
|
interfaces, thyname})
|
|
|
|
= Enumeration{name=name, parent=parent, operations=oper::operations,
|
|
|
|
literals=literals, invariant=invariant, stereotypes=stereotypes,
|
|
|
|
interfaces=interfaces, thyname=thyname}
|
|
|
|
| addOperation oper (Primitive {name, parent, operations,
|
|
|
|
associations, invariant,
|
|
|
|
stereotypes, interfaces, thyname})
|
|
|
|
= Primitive{name=name, parent=parent, operations=oper::operations,
|
|
|
|
associations=associations, invariant=invariant,
|
|
|
|
stereotypes=stereotypes, interfaces=interfaces, thyname=thyname}
|
|
|
|
| addOperation oper (Template {parameter, classifier})
|
|
|
|
= Template { parameter=parameter,
|
|
|
|
classifier=addOperation oper classifier
|
|
|
|
}
|
|
|
|
|
2005-08-17 15:45:10 +00:00
|
|
|
end
|