Skip to content

Commit 2aea88d

Browse files
author
thk123
committed
Made generate_start_function abstract
Made the generat_start_function abstract to ensure new langugages are at least aware they should provide implemention for this method. CPP and JSIL languages have stub method that asserts for now.
1 parent f0d6d72 commit 2aea88d

File tree

6 files changed

+41
-18
lines changed

6 files changed

+41
-18
lines changed

src/cpp/cpp_language.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ void cpp_languaget::modules_provided(std::set<std::string> &modules)
5353
modules.insert(get_base_name(parse_path, true));
5454
}
5555

56+
/// Generate a _start function for a specific function
57+
/// \param entry_function_symbol: The symbol for the function that should be
58+
/// used as the entry point
59+
/// \param symbol_table: The symbol table for the program. The new _start
60+
/// function symbol will be added to this table
61+
/// \return Returns false if the _start method was generated correctly
62+
bool cpp_languaget::generate_start_function(
63+
const symbolt &entry_function_symbol,
64+
symbol_tablet &symbol_table)
65+
{
66+
return generate_ansi_c_start_function(
67+
entry_function_symbol,
68+
symbol_table,
69+
*message_handler);
70+
}
71+
5672
/// ANSI-C preprocessing
5773
bool cpp_languaget::preprocess(
5874
std::istream &instream,

src/cpp/cpp_language.h

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ class cpp_languaget:public languaget
8585

8686
void modules_provided(std::set<std::string> &modules) override;
8787

88+
virtual bool generate_start_function(
89+
const class symbolt &entry_function_symbol,
90+
class symbol_tablet &symbol_table) override;
91+
8892
protected:
8993
cpp_parse_treet cpp_parse_tree;
9094
std::string parse_path;

src/jsil/jsil_language.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ bool jsil_languaget::interfaces(symbol_tablet &symbol_table)
4141
return false;
4242
}
4343

44+
/// Generate a _start function for a specific function
45+
/// \param entry_function_symbol: The symbol for the function that should be
46+
/// used as the entry point
47+
/// \param symbol_table: The symbol table for the program. The new _start
48+
/// function symbol will be added to this table
49+
/// \return Returns false if the _start method was generated correctly
50+
bool jsil_languaget::generate_start_function(
51+
const symbolt &entry_function_symbol,
52+
symbol_tablet &symbol_table)
53+
{
54+
// TODO(tkiley): This should be implemented if this language
55+
// is used.
56+
UNREACHABLE;
57+
return true;
58+
}
59+
4460
bool jsil_languaget::preprocess(
4561
std::istream &instream,
4662
const std::string &path,

src/jsil/jsil_language.h

+4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ class jsil_languaget:public languaget
6969
virtual void modules_provided(std::set<std::string> &modules);
7070
virtual bool interfaces(symbol_tablet &symbol_table);
7171

72+
virtual bool generate_start_function(
73+
const class symbolt &entry_function_symbol,
74+
class symbol_tablet &symbol_table) override;
75+
7276
protected:
7377
jsil_parse_treet parse_tree;
7478
std::string parse_path;

src/util/language.cpp

-17
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,3 @@ void languaget::generate_opaque_parameter_symbols(
191191
symbol_table.add(param_symbol);
192192
}
193193
}
194-
195-
/// Generate a entry function for a specific function. Should be overriden in
196-
/// derived languagets
197-
/// \param entry_function_symbol: The symbol for the function that should be
198-
/// used as the entry point
199-
/// \param symbol_table: The symbol table for the program. The new _start
200-
/// function symbol will be added to this table
201-
/// \return Returns false if the entry method was generated correctly
202-
bool languaget::generate_start_function(
203-
const symbolt &entry_function_symbol,
204-
symbol_tablet &symbol_table)
205-
{
206-
// Implement in derived languagets
207-
assert(0);
208-
return true;
209-
}
210-

src/util/language.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class languaget:public messaget
121121

122122
virtual bool generate_start_function(
123123
const class symbolt &entry_function_symbol,
124-
class symbol_tablet &symbol_table);
124+
class symbol_tablet &symbol_table)=0;
125125

126126
// constructor / destructor
127127

0 commit comments

Comments
 (0)