Skip to content

Commit 61d9ea8

Browse files
committed
Give languaget a private typecheck method
This is to avoid breaking the API while introducing a new parameter, symbols_to_keep. This parameter will be used in a later commit that will prevent the typecheck method from stripping out user-requested symbols.
1 parent 28950eb commit 61d9ea8

File tree

11 files changed

+48
-22
lines changed

11 files changed

+48
-22
lines changed

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,10 @@ static void create_stub_global_symbols(
640640
}
641641
}
642642

643-
bool java_bytecode_languaget::typecheck(
643+
bool java_bytecode_languaget::prv_typecheck(
644644
symbol_tablet &symbol_table,
645-
const std::string &)
645+
const std::string &module,
646+
const std::set<std::string> &symbols_to_keep)
646647
{
647648
PRECONDITION(language_options_initialized);
648649

jbmc/src/java_bytecode/java_bytecode_language.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ class java_bytecode_languaget:public languaget
102102
bool generate_support_functions(
103103
symbol_tablet &symbol_table) override;
104104

105-
bool typecheck(
105+
bool prv_typecheck(
106106
symbol_tablet &context,
107-
const std::string &module) override;
107+
const std::string &module,
108+
const std::set<std::string> &symbols_to_keep) override;
108109

109110
virtual bool final(symbol_table_baset &context) override;
110111

src/ansi-c/ansi_c_language.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ bool ansi_c_languaget::parse(
103103
return result;
104104
}
105105

106-
bool ansi_c_languaget::typecheck(
106+
bool ansi_c_languaget::prv_typecheck(
107107
symbol_tablet &symbol_table,
108-
const std::string &module)
108+
const std::string &module,
109+
const std::set<std::string> &symbols_to_keep)
109110
{
110111
symbol_tablet new_symbol_table;
111112

src/ansi-c/ansi_c_language.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@ class ansi_c_languaget:public languaget
5151
bool generate_support_functions(
5252
symbol_tablet &symbol_table) override;
5353

54-
bool typecheck(
54+
private:
55+
bool prv_typecheck(
5556
symbol_tablet &symbol_table,
56-
const std::string &module) override;
57+
const std::string &module,
58+
const std::set<std::string> &symbols_to_keep) override;
5759

60+
public:
5861
void show_parse(std::ostream &out) override;
5962

6063
~ansi_c_languaget() override;

src/cpp/cpp_language.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ bool cpp_languaget::parse(
119119
return result;
120120
}
121121

122-
bool cpp_languaget::typecheck(
122+
bool cpp_languaget::prv_typecheck(
123123
symbol_tablet &symbol_table,
124-
const std::string &module)
124+
const std::string &module,
125+
const std::set<std::string> &symbols_to_keep)
125126
{
126127
if(module=="")
127128
return false;

src/cpp/cpp_language.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ class cpp_languaget:public languaget
4242
bool generate_support_functions(
4343
symbol_tablet &symbol_table) override;
4444

45-
bool typecheck(
45+
bool prv_typecheck(
4646
symbol_tablet &symbol_table,
47-
const std::string &module) override;
47+
const std::string &module,
48+
const std::set<std::string> &symbols_to_keep) override;
4849

4950
bool merge_symbol_table(
5051
symbol_tablet &dest,

src/jsil/jsil_language.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,10 @@ bool jsil_languaget::parse(
7676
}
7777

7878
/// Converting from parse tree and type checking.
79-
bool jsil_languaget::typecheck(
79+
bool jsil_languaget::prv_typecheck(
8080
symbol_tablet &symbol_table,
81-
const std::string &)
81+
const std::string &,
82+
const std::set<std::string> &symbols_to_keep)
8283
{
8384
if(jsil_typecheck(symbol_table, get_message_handler()))
8485
return true;

src/jsil/jsil_language.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ class jsil_languaget:public languaget
3535
virtual bool generate_support_functions(
3636
symbol_tablet &symbol_table) override;
3737

38-
virtual bool typecheck(
38+
private:
39+
virtual bool prv_typecheck(
3940
symbol_tablet &context,
40-
const std::string &module) override;
41+
const std::string &module,
42+
const std::set<std::string> &symbols_to_keep) override;
4143

44+
public:
4245
virtual void show_parse(std::ostream &out) override;
4346

4447
virtual ~jsil_languaget();

src/json-symtab-language/json_symtab_language.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ bool json_symtab_languaget::parse(
2828
/// \param symbol_table: The symbol table containing symbols read from file.
2929
/// \param module: A useless parameter, there for interface consistency.
3030
/// \return boolean signifying success or failure of the typechecking.
31-
bool json_symtab_languaget::typecheck(
31+
bool json_symtab_languaget::prv_typecheck(
3232
symbol_tablet &symbol_table,
33-
const std::string &module)
33+
const std::string &module,
34+
const std::set<std::string> &symbols_to_keep)
3435
{
3536
(void)module; // unused parameter
3637

src/json-symtab-language/json_symtab_language.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ class json_symtab_languaget : public languaget
2424
public:
2525
bool parse(std::istream &instream, const std::string &path) override;
2626

27-
bool
28-
typecheck(symbol_tablet &symbol_table, const std::string &module) override;
27+
bool prv_typecheck(
28+
symbol_tablet &symbol_table,
29+
const std::string &module,
30+
const std::set<std::string> &symbols_to_keep) override;
2931

3032
void show_parse(std::ostream &out) override;
3133

src/langapi/language.h

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,22 @@ class languaget:public messaget
117117
virtual bool interfaces(
118118
symbol_tablet &symbol_table);
119119

120+
private:
121+
virtual bool prv_typecheck(
122+
symbol_tablet &symbol_table,
123+
const std::string &module,
124+
const std::set<std::string> &symbols_to_keep) = 0;
125+
120126
// type check a module in the currently parsed file
121127

122-
virtual bool typecheck(
128+
public:
129+
bool typecheck(
123130
symbol_tablet &symbol_table,
124-
const std::string &module)=0;
131+
const std::string &module,
132+
const std::set<std::string> &symbols_to_keep = {})
133+
{
134+
return prv_typecheck(symbol_table, module, symbols_to_keep);
135+
}
125136

126137
// language id / description
127138

0 commit comments

Comments
 (0)