Determine if class being compiled conforms to another

27 views
Skip to first unread message

Jimmy Johnson

unread,
Mar 26, 2015, 11:55:11 PM3/26/15
to eiffelst...@googlegroups.com
 Alexander,
The help that you a Manu provided has been great.  A couple of more questions.

1)  How can the compiler determine in feature `process_assign_as' from AST_FEATURE_CHECKER_GENERATOR if the class being processed is a particular class, say INTEGER_32?

2)  How can the compiler (same feature) determine if the class being process conforms to a particular class? 

Thanks,
jjj

Jimmy Johnson

unread,
Mar 27, 2015, 10:12:39 AM3/27/15
to eiffelst...@googlegroups.com
Now that I think about it, is there a way to determine if the class being compiled is in a particular cluster, say "base" cluster?
jjj

Alexander Kogtenkov

unread,
Mar 27, 2015, 4:05:19 PM3/27/15
to eiffelst...@googlegroups.com
> 1)  How can the compiler determine in feature `process_assign_as' from AST_FEATURE_CHECKER_GENERATOR if the class being processed is a particular class, say INTEGER_32?

context.current_class.name_in_upper ~ "INTEGER_32"

> 2)  How can the compiler (same feature) determine if the class being process conforms to a particular class? 

context.current_class.conform_to (other_class_c)

> is there a way to determine if the class being compiled is in a particular cluster, say "base" cluster?


Alexander Kogtenkov

--
For more messaging options, visit this group at http://forum.eiffel.com.
Information on the Eiffelstudio project: http://dev.eiffel.com.

Emmanuel Stapf

unread,
Mar 27, 2015, 4:12:24 PM3/27/15
to eiffelst...@googlegroups.com

Note that for answer #1 and checking if a class is from EiffelBase, comparing strings is not ideal. If you really want to know if the class in INTEGER or one of the basic expanded class, it is best to write `context.current_class.is_basic’.

 

For the group, I think it is best to not use the group’s name since it is dependent on the ECF of the project. It might be best from the group to find the corresponding library target and then compare it to the UUID of EiffelBase which is guaranteed to be unique and not to change.

 

Manu

Jimmy Johnson

unread,
Mar 28, 2015, 1:58:42 PM3/28/15
to eiffelst...@googlegroups.com
Thanks Manu and Alexander.

> 2)  How can the compiler (same feature) determine if the class being process conforms to a particular class? 

context.current_class.conform_to (other_class_c)
  
How do I get `other_class_c'?

jjj 

Alexander Kogtenkov

unread,
Mar 28, 2015, 2:10:25 PM3/28/15
to eiffelst...@googlegroups.com
You can use either

   universe.classes_with_name
or
   universe.class_named

and then call `compiled_class' to get CLASS_C.

Alexander Kogtenkov

--

Jimmy Johnson

unread,
Apr 6, 2015, 3:50:03 PM4/6/15
to eiffelst...@googlegroups.com
> is there a way to determine if the class being compiled is in a particular cluster, say "base" cluster?

Does this also work for a sub-cluster, such as "base/elks/kernel" ?

Alexander Kogtenkov

unread,
Apr 7, 2015, 4:47:30 AM4/7/15
to eiffelst...@googlegroups.com
It's better if you check yourself. There are at least two options to have a "subcluster". One is to mark a cluster as recursive. And the other is to specify nested clusters explicitly. I do not know how these cases are handled in terms of (sub)cluster names.

Alexander Kogtenkov

--
Reply all
Reply to author
Forward
0 new messages