@@ -4696,45 +4696,93 @@ inline array_comprehension_exprt &to_array_comprehension_expr(exprt &expr)
46964696 return ret;
46974697}
46984698
4699+ inline void validate_expr (const class class_method_descriptor_exprt &value);
4700+
46994701// / An expression describing a method on a class
47004702class class_method_descriptor_exprt : public nullary_exprt
47014703{
47024704public:
4705+ // / \param _type: The type of the method which this expression refers to.
4706+ // / \param class_id: Unique identifier in the symbol table, of the compile
4707+ // / time type of the class which this expression is applied to. For example
4708+ // / this could be - `java::java.lang.Object`.
4709+ // / \param base_method_name: The name of the method to which this expression
4710+ // / is applied as would be seen in the source code. For example this could
4711+ // / be - `toString`.
4712+ // / \param mangled_method_name: The method name after mangling it by
4713+ // / combining it with the descriptor. The mangled name is distinguished from
4714+ // / other overloads of the method with different counts of or types of
4715+ // / parameters. It is not distinguished between different implementations
4716+ // / within a class hierarchy. For example if the overall expression refers
4717+ // / to the `java.lang.Object.toString` method, then the mangled_method_name
4718+ // / would be `toString:()Ljava/lang/String;`
47034719 explicit class_method_descriptor_exprt (
47044720 typet _type,
4705- irep_idt component_name,
4706- irep_idt class_name,
4707- irep_idt base_name,
4708- irep_idt identifier)
4721+ irep_idt mangled_method_name,
4722+ irep_idt class_id,
4723+ irep_idt base_method_name)
47094724 : nullary_exprt(ID_virtual_function, std::move(_type))
47104725 {
4711- set (ID_component_name, std::move (component_name));
4712- set (ID_C_class, std::move (class_name));
4713- set (ID_C_base_name, std::move (base_name));
4714- set (ID_identifier, std::move (identifier));
4726+ irep_idt id = id2string (class_id) + " ." + id2string (mangled_method_name);
4727+ set (ID_component_name, std::move (mangled_method_name));
4728+ set (ID_C_class, std::move (class_id));
4729+ set (ID_C_base_name, std::move (base_method_name));
4730+ set (ID_identifier, std::move (id));
4731+ validate_expr (*this );
47154732 }
47164733
4717- const irep_idt &get_component_name () const
4734+ // / The method name after mangling it by combining it with the descriptor.
4735+ // / The mangled name is distinguished from other overloads of the method with
4736+ // / different counts of or types of parameters. It is not distinguished
4737+ // / between different implementations within a class hierarchy. For example if
4738+ // / the overall expression refers to the `java.lang.Object.toString` method,
4739+ // / then the mangled_method_name would be `toString:()Ljava/lang/String;`
4740+ const irep_idt &mangled_method_name () const
47184741 {
47194742 return get (ID_component_name);
47204743 }
47214744
4722- const irep_idt &get_class_name () const
4745+ // / Unique identifier in the symbol table, of the compile time type of the
4746+ // / class which this expression is applied to. For example this could be -
4747+ // / `java::java.lang.Object`.
4748+ const irep_idt &class_id () const
47234749 {
47244750 return get (ID_C_class);
47254751 }
47264752
4727- const irep_idt &get_base_name () const
4753+ // / The name of the method to which this expression is applied as would be
4754+ // / seen in the source code. For example this could be - `toString`.
4755+ const irep_idt &base_method_name () const
47284756 {
47294757 return get (ID_C_base_name);
47304758 }
47314759
4760+ // / A unique identifier of the combination of class and method overload to
4761+ // / which this expression refers. For example this could be -
4762+ // / `java::java.lang.Object.toString:()Ljava/lang/String;`.
47324763 const irep_idt &get_identifier () const
47334764 {
47344765 return get (ID_identifier);
47354766 }
47364767};
47374768
4769+ inline void validate_expr (const class class_method_descriptor_exprt &value)
4770+ {
4771+ validate_operands (value, 0 , " class method descriptor must not have operands" );
4772+ DATA_INVARIANT (
4773+ !value.mangled_method_name ().empty (),
4774+ " class method descriptor must have a mangled method name." );
4775+ DATA_INVARIANT (
4776+ !value.class_id ().empty (), " class method descriptor must have a class id." );
4777+ DATA_INVARIANT (
4778+ !value.base_method_name ().empty (),
4779+ " class method descriptor must have a base method name." );
4780+ DATA_INVARIANT (
4781+ value.get_identifier () == id2string (value.class_id ()) + " ." +
4782+ id2string (value.mangled_method_name ()),
4783+ " class method descriptor must have an identifier in the expected format." );
4784+ }
4785+
47384786// / \brief Cast an exprt to a \ref class_method_descriptor_exprt
47394787// /
47404788// / \a expr must be known to be \ref class_method_descriptor_exprt.
0 commit comments