Skip to content

Commit

Permalink
First draft of feature arguments and conforms to.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sune Alkærsig authored and Sune Alkærsig committed Apr 17, 2012
1 parent 216a460 commit 1857fc3
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/type_checker/tbon_tc_error.e
Expand Up @@ -36,6 +36,7 @@ feature -- Access
feature -- Error codes feature -- Error codes


err_code_ancestor_does_not_exist, err_code_ancestor_does_not_exist,
err_code_argument_type_does_not_exist,
err_code_class_already_in_cluster, err_code_class_already_in_cluster,
err_code_class_does_not_exist, err_code_class_does_not_exist,
err_code_class_exists, err_code_class_exists,
Expand Down
11 changes: 11 additions & 0 deletions src/type_checker/tbon_tc_text_items.e
Expand Up @@ -39,6 +39,17 @@ feature -- Error messages
Result.append_string (" does not exist.") Result.append_string (" does not exist.")
end end


err_argument_type_does_not_exist(an_argument_name, a_feature_name, a_class_name: STRING): STRING
do
Result := "Type of argument "
Result.append_string (an_argument_name.string)
Result.append_string (" in feature ")
Result.append_string (a_feature_name.string)
Result.append_string (" in class ")
Result.append_string (a_class_name.string)
Result.append_string (" could not be found.")
end

err_class_already_in_cluster (a_name: STRING): STRING err_class_already_in_cluster (a_name: STRING): STRING
do do
Result := "Error defining cluster " Result := "Error defining cluster "
Expand Down
39 changes: 38 additions & 1 deletion src/type_checker/textual_bon_type_checker.e
Expand Up @@ -1066,6 +1066,43 @@ feature -- Type checking, static diagrams
end end
end end


check_feature_arguments(an_element: FEATURE_ARGUMENT_LIST; enclosing_feature: FEATURE_SPECIFICATION; enclosing_class: TBON_TC_CLASS_TYPE): BOOLEAN
note
rule: "[
In an environment where all arguments are OK,
and if the feature is redefined all arguments conform to its precursors,
`an_element' is OK.
]"
local
l_argument: FEATURE_ARGUMENT
l_string_list: STRING_LIST
do
Result := True
if enclosing_feature.has_arguments then
if first_phase then
from an_element.start until an_element.after loop
if an_element.item_for_iteration.identifiers.item_for_iteration.count > 1 then
from an_element.item_for_iteration.identifiers.start until an_element.item_for_iteration.identifiers.after loop
create l_string_list.make_list (an_element.item_for_iteration.identifiers.item_for_iteration)
create l_argument.make (l_string_list, an_element.item_for_iteration.type)
an_element.put_last (l_argument)
end
an_element.remove_at
else
an_element.forth
end
end
Result := an_element.for_all (agent (argument: FEATURE_ARGUMENT): BOOLEAN
do

end
)
elseif second_phase then

end
end
end

check_feature_clause (an_element: FEATURE_CLAUSE; enclosing_class: TBON_TC_CLASS_TYPE): BOOLEAN check_feature_clause (an_element: FEATURE_CLAUSE; enclosing_class: TBON_TC_CLASS_TYPE): BOOLEAN
-- Does `an_element' type check as a type FEATURE_CLAUSE? -- Does `an_element' type check as a type FEATURE_CLAUSE?
note note
Expand Down Expand Up @@ -1110,7 +1147,7 @@ feature -- Type checking, static diagrams
and the type of the feature is in the environment, and the type of the feature is in the environment,
and all feature arguments are OK, and all feature arguments are OK,
and if renamed is renamed consistently, and if renamed is renamed consistently,
]" ]"
do do
if then if then
Expand Down
24 changes: 19 additions & 5 deletions src/type_checker/types/tbon_tc_class_type.e
Expand Up @@ -124,12 +124,26 @@ feature -- Status report
conforms_to (other: TBON_TC_TYPE): BOOLEAN conforms_to (other: TBON_TC_TYPE): BOOLEAN
-- Does `Current' conform to `other'? -- Does `Current' conform to `other'?
local local
class_type: TBON_TC_CLASS_TYPE l_ancestors: like Current.ancestors
do do
class_type ?= other if Current |=| other then

Result := True
if class_type /= Void then elseif not attached {TBON_TC_CLUSTER_TYPE} other then

l_ancestors := Current.ancestors
Result := l_ancestors.exists (
agent (type: TBON_TC_CLASS_TYPE; l_other: TBON_TC_TYPE): BOOLEAN
do
Result := type |=| l_other
end (?, other)
)
if not Result then
Result := l_ancestors.for_all (
agent (type: TBON_TC_CLASS_TYPE; l_other: TBON_TC_TYPE): BOOLEAN
do
Result := type.conforms_to (l_other)
end (?, other)
)
end
else else
Result := False Result := False
end end
Expand Down

0 comments on commit 1857fc3

Please sign in to comment.