@@ -102,6 +102,10 @@ class no_unique_unimplemented_method_exceptiont : public std::exception
102102 const std::string message;
103103};
104104
105+ // / Find the unique abstract method that isn't equals(...) or hashCode() in a
106+ // / list of methods. Returns the method's symbol-table identifier if one is
107+ // / found, or empty if there are no matching methods, or throws
108+ // / no_unique_unimplemented_method_exceptiont if there are at least two.
105109static optionalt<irep_idt> get_unique_abstract_method (
106110 const java_class_typet::methodst &methods,
107111 const namespacet &ns)
@@ -131,6 +135,10 @@ static optionalt<irep_idt> get_unique_abstract_method(
131135 return result;
132136}
133137
138+ // / Find the unique unimplemented method on a given interface type, including
139+ // / considering its parents. Returns the method's symbol-table identifier if one
140+ // / is found, or empty if there are no unimplemented methods, or throws
141+ // / no_unique_unimplemented_method_exceptiont if there are at least two.
134142static optionalt<irep_idt> get_unique_unimplemented_method (
135143 const irep_idt &interface_id,
136144 const namespacet &ns)
@@ -529,6 +537,16 @@ static symbol_exprt create_and_declare_local(
529537 return new_instance_var;
530538}
531539
540+ // / Instantiates an object suitable for calling a given constructor (but does
541+ // / not actually call it). Adds a local to symbol_table, and code implementing
542+ // / the required operation to result; returns a symbol carrying a reference to
543+ // / the newly instantiated object.
544+ // / \param function_id: ID of the function that `result` falls within
545+ // / \param lambda_method_symbol: the constructor that will be called, and so
546+ // / whose `this` parameter we should instantiate.
547+ // / \param symbol_table: symbol table, will gain a local variable
548+ // / \param result: will gain instructions instantiating the required type
549+ // / \return the newly instantiated symbol
532550static symbol_exprt instantiate_new_object (
533551 const irep_idt &function_id,
534552 const symbolt &lambda_method_symbol,
@@ -566,6 +584,22 @@ static symbol_exprt instantiate_new_object(
566584 return new_instance_var;
567585}
568586
587+ // / Create the body for the synthetic method implementing an invokedynamic
588+ // / method. For most lambdas this means creating a simple function body like
589+ // / TR new_synthetic_method(T1 param1, T2 param2, ...) {
590+ // / return target_method(capture1, capture2, ..., param1, param2, ...);
591+ // / }, where the first parameter might be a `this` parameter.
592+ // / For a constructor method, the generated code will be of the form
593+ // / TNew new_synthetic_method(T1 param1, T2 param2, ...) {
594+ // / return new TNew(capture1, capture2, ..., param1, param2, ...);
595+ // / }
596+ // / i.e. the TNew object will be both instantiated and constructed.
597+ // / \param function_id: synthetic method whose body should be generated;
598+ // / information about the lambda method to generate has already been stored
599+ // / in the symbol table by create_invokedynamic_synthetic_classes.
600+ // / \param symbol_table: will gain local variable symbols
601+ // / \param message_handler: log
602+ // / \return the method body for `function_id`
569603codet invokedynamic_synthetic_method (
570604 const irep_idt &function_id,
571605 symbol_table_baset &symbol_table,
0 commit comments