Skip to content

Commit

Permalink
remove mathematical_typet() constructor, which produces an incomplete…
Browse files Browse the repository at this point in the history
… object
  • Loading branch information
Daniel Kroening committed May 29, 2018
1 parent 25d393b commit 1fe7cd7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
30 changes: 16 additions & 14 deletions src/solvers/smt2/smt2_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1028,26 +1028,27 @@ typet smt2_parsert::function_signature_definition()
return sort();
}

mathematical_function_typet result;
mathematical_function_typet::domaint domain;

while(peek()!=CLOSE)
{
if(next_token()!=OPEN)
{
error() << "expected '(' at beginning of parameter" << eom;
return result;
return nil_typet();
}

if(next_token()!=SYMBOL)
{
error() << "expected symbol in parameter" << eom;
return result;
return nil_typet();
}

auto &var=result.add_variable();
mathematical_function_typet::variablet var;
std::string id=buffer;
var.set_identifier(id);
var.type()=sort();
domain.push_back(var);

auto &entry=id_map[id];
entry.type=var.type();
Expand All @@ -1056,15 +1057,15 @@ typet smt2_parsert::function_signature_definition()
if(next_token()!=CLOSE)
{
error() << "expected ')' at end of parameter" << eom;
return result;
return nil_typet();
}
}

next_token(); // eat the ')'

result.codomain()=sort();
typet codomain = sort();

return result;
return mathematical_function_typet(domain, codomain);
}

typet smt2_parsert::function_signature_declaration()
Expand All @@ -1081,37 +1082,38 @@ typet smt2_parsert::function_signature_declaration()
return sort();
}

mathematical_function_typet result;
mathematical_function_typet::domaint domain;

while(peek()!=CLOSE)
{
if(next_token()!=OPEN)
{
error() << "expected '(' at beginning of parameter" << eom;
return result;
return nil_typet();
}

if(next_token()!=SYMBOL)
{
error() << "expected symbol in parameter" << eom;
return result;
return nil_typet();
}

auto &var=result.add_variable();
mathematical_function_typet::variablet var;
var.type()=sort();
domain.push_back(var);

if(next_token()!=CLOSE)
{
error() << "expected ')' at end of parameter" << eom;
return result;
return nil_typet();
}
}

next_token(); // eat the ')'

result.codomain()=sort();
typet codomain = sort();

return result;
return mathematical_function_typet(domain, codomain);
}

void smt2_parsert::command(const std::string &c)
Expand Down
13 changes: 8 additions & 5 deletions src/util/std_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1686,11 +1686,6 @@ inline complex_typet &to_complex_type(typet &type)
class mathematical_function_typet:public typet
{
public:
mathematical_function_typet():typet(ID_mathematical_function)
{
subtypes().resize(2);
}

// the domain of the function is composed of zero, one, or
// many variables
class variablet:public irept
Expand Down Expand Up @@ -1720,6 +1715,14 @@ class mathematical_function_typet:public typet

using domaint=std::vector<variablet>;

mathematical_function_typet(const domaint &_domain, const typet &_codomain)
: typet(ID_mathematical_function)
{
subtypes().resize(2);
domain() = _domain;
codomain() = _codomain;
}

domaint &domain()
{
return (domaint &)subtypes()[0].subtypes();
Expand Down

0 comments on commit 1fe7cd7

Please sign in to comment.