added init to assoc_ends and attributes and introduced a type 'attribute'

git-svn-id: https://projects.brucker.ch/su4sml/svn/infsec-import/trunk/src/su4sml@3287 3260e6d1-4efc-4170-b0a7-36055960796d
This commit is contained in:
Achim D. Brucker 2005-11-01 07:32:21 +00:00
parent e03d096f11
commit d29962fec9
3 changed files with 53 additions and 27 deletions

View File

@ -40,15 +40,23 @@ type associationend = {name : string,
aend_type : Rep_OclType.OclType,
multiplicity: (int * int) list,
ordered: bool,
visibility: Visibility
}
visibility: Visibility,
init: (string option * Rep_OclTerm.OclTerm) option
}
type attribute = {
name : string,
attr_type : Rep_OclType.OclType,
visibility : Visibility,
scope: Scope,
init : (string option * Rep_OclTerm.OclTerm) option
}
datatype Classifier =
Class of
{ name : Rep_OclType.Path,
parent : Rep_OclType.Path option,
attributes : (string * Rep_OclType.OclType * Visibility * Scope) list,
attributes : attribute list,
operations : operation list,
associationends : associationend list,
invariant : (string option * Rep_OclTerm.OclTerm) list,
@ -100,7 +108,7 @@ val short_parent_name_of : Classifier -> string
val thy_name_of : Classifier -> string
val update_thyname : string -> Classifier -> Classifier
val attributes_of : Classifier -> (string * Rep_OclType.OclType * Visibility * Scope) list
val attributes_of : Classifier -> attribute list
val operations_of : Classifier -> operation list
val invariant_of : Classifier -> (string option * Rep_OclTerm.OclTerm) list
val string_of_path : string list -> string

View File

@ -38,17 +38,31 @@ type operation = { name : string,
visibility : Visibility,
scope : Scope }
type associationend = {name : string,
aend_type: Rep_OclType.OclType,
multiplicity: (int*int) list,
visibility: Visibility,
ordered: bool }
type associationend = {
name : string,
aend_type: Rep_OclType.OclType,
multiplicity: (int*int) list,
visibility: Visibility,
ordered: bool,
init : (string option * Rep_OclTerm.OclTerm) option
}
type attribute = {
name : string,
attr_type : Rep_OclType.OclType,
visibility : Visibility,
scope: Scope,
init : (string option * Rep_OclTerm.OclTerm) option
}
datatype Classifier =
Class of
{ name : Rep_OclType.Path,
parent : Rep_OclType.Path option,
attributes : (string * Rep_OclType.OclType * Visibility * Scope) list,
attributes : attribute list,
operations : operation list,
associationends : associationend list,
invariant : (string option * Rep_OclTerm.OclTerm) list,
@ -87,7 +101,7 @@ datatype Classifier =
}
(* convert an association end into the corresponding collection type *)
fun assoc_to_attr_type {name,aend_type,multiplicity,ordered,visibility} =
fun assoc_to_attr_type {name,aend_type,multiplicity,ordered,visibility,init} =
case multiplicity of
[(0,1)] => aend_type
| [(1,1)] => aend_type
@ -96,10 +110,11 @@ fun assoc_to_attr_type {name,aend_type,multiplicity,ordered,visibility} =
(* convert an association end into an attribute of the *)
(* corresponding collection type *)
fun assoc_to_attr (assoc:associationend) = (#name assoc,
assoc_to_attr_type assoc,
#visibility assoc,
XMI.InstanceScope)
fun assoc_to_attr (assoc:associationend) = {name = #name assoc,
attr_type = assoc_to_attr_type assoc,
visibility = #visibility assoc,
scope = XMI.InstanceScope,
init = #init assoc}
(* convert a multiplicity range into an invariant of the form *)
(* size > lowerBound and size < upperBound ) *)
@ -144,7 +159,8 @@ fun range_to_inv cls_name aend (a,b) =
fun assoc_to_inv cls_name (aend:associationend) =
let val inv_name = "multiplicity_constraint_for_association_end_"^(#name aend)
val range_constraints = case (#multiplicity aend) of
[(0,1)] => let
[(0,1)] => []
| [(1,1)] => let
val attr_name = cls_name@[#name aend]
val attr_type = assoc_to_attr_type aend
val cls = Rep_OclType.Classifier cls_name
@ -155,7 +171,6 @@ fun assoc_to_inv cls_name (aend:associationend) =
["oclIsDefined"],[],
Rep_OclType.Boolean)]
end
| [(1,1)] => [] (* FIXME: should be aend->OclIsDefined() *)
| _ => map (range_to_inv cls_name aend)
(#multiplicity aend)
fun ocl_or (x,y) =

View File

@ -135,14 +135,15 @@ fun transform_attribute t ({xmiid,name,type_id,changeability,visibility,ordering
multiplicity,taggedValue,ownerScope,targetScope}) =
let val cls_type = find_classifier_type t type_id
in
(name,
if multiplicity = [(1,1)]
then cls_type
else if ordering = XMI.Ordered then Rep_OclType.Sequence cls_type
else Rep_OclType.Set cls_type,
visibility,
ownerScope
)
{name= name,
attr_type = if multiplicity = [(1,1)]
then cls_type
else if ordering = XMI.Ordered then Rep_OclType.Sequence cls_type
else Rep_OclType.Set cls_type,
visibility = visibility,
scope = ownerScope,
init = NONE (* FIX *)
}
end
fun transform_aend t ({xmiid,name,ordering,multiplicity,participant_id,
@ -151,7 +152,9 @@ fun transform_aend t ({xmiid,name,ordering,multiplicity,participant_id,
aend_type = find_classifier_type t participant_id,
multiplicity = multiplicity,
ordered = if ordering = XMI.Ordered then true else false,
visibility = visibility }
visibility = visibility,
init = NONE (* FIX *)
}
val filter_named_aends = List.filter (fn {name=SOME _,...}:XMI.AssociationEnd => true
| _ => false)