Commit c5804869 authored by Elwin Pater's avatar Elwin Pater Committed by Michael Weber
Browse files

Added co-enabled detection for const array index

parent fe632e5f
...@@ -2398,26 +2398,50 @@ bool dve_compiler::get_const_expression( dve_expression_t & expr, int & value) ...@@ -2398,26 +2398,50 @@ bool dve_compiler::get_const_expression( dve_expression_t & expr, int & value)
return false; return false;
} }
void dve_compiler::extract_predicates( std::vector<simple_predicate>& p, dve_expression_t& expr) bool dve_compiler::get_const_varname( dve_expression_t & expr, string& var)
{ {
string var_square_bracket;
dve_symbol_table_t * parent_table = expr.get_symbol_table(); dve_symbol_table_t * parent_table = expr.get_symbol_table();
if (!parent_table) gerr << "Extract predicates: Symbol table not set" << thr(); if (!parent_table) gerr << "Get const var: Symbol table not set" << thr();
switch (expr.get_operator()) switch (expr.get_operator())
{ {
case T_PARENTHESIS: case T_SQUARE_BRACKETS:
return extract_predicates(p, *expr.left()); int val;
case T_LT: case T_LEQ: case T_EQ: case T_NEQ: case T_GT: case T_GEQ: if (get_const_expression(*expr.left(), val)) {
if ((*expr.left()).get_operator() == T_ID) { var_square_bracket = "[" + fmt(val) + "]";
simple_predicate sp; } else {
if (get_const_expression(*expr.right(), sp.variable_value) ) { return false;
}
// fall through
case T_ID:
{
string proc_part(""); string proc_part("");
string var_part(parent_table->get_variable((expr.left())->get_ident_gid())->get_name()); string var_part(parent_table->get_variable(expr.get_ident_gid())->get_name());
if (parent_table->get_variable(expr.get_ident_gid())->get_process_gid() != NO_ID) { if (parent_table->get_variable(expr.get_ident_gid())->get_process_gid() != NO_ID) {
proc_part = parent_table->get_process(parent_table->get_variable(expr.get_ident_gid())-> proc_part = parent_table->get_process(parent_table->get_variable(expr.get_ident_gid())->
get_process_gid())->get_name(); get_process_gid())->get_name();
proc_part += "."; proc_part += ".";
} }
sp.variable_name = proc_part + var_part; var = proc_part + var_part + var_square_bracket;
}
return true;
default:
var = "";
}
return false;
}
void dve_compiler::extract_predicates( std::vector<simple_predicate>& p, dve_expression_t& expr)
{
dve_symbol_table_t * parent_table = expr.get_symbol_table();
if (!parent_table) gerr << "Extract predicates: Symbol table not set" << thr();
switch (expr.get_operator())
{
case T_PARENTHESIS:
return extract_predicates(p, *expr.left());
case T_LT: case T_LEQ: case T_EQ: case T_NEQ: case T_GT: case T_GEQ: {
simple_predicate sp;
if (get_const_varname(*expr.left(), sp.variable_name)) {
if (get_const_expression(*expr.right(), sp.variable_value) ) {
switch(expr.get_operator()) { switch(expr.get_operator()) {
case T_LT: sp.relation = PRED_LT; break; case T_LT: sp.relation = PRED_LT; break;
case T_LEQ: sp.relation = PRED_LEQ; break; case T_LEQ: sp.relation = PRED_LEQ; break;
...@@ -2429,7 +2453,7 @@ void dve_compiler::extract_predicates( std::vector<simple_predicate>& p, dve_exp ...@@ -2429,7 +2453,7 @@ void dve_compiler::extract_predicates( std::vector<simple_predicate>& p, dve_exp
p.push_back(sp); p.push_back(sp);
} }
} }
break; } break;
case T_BOOL_AND: case T_BOOL_AND:
{ {
extract_predicates( p, *expr.left()); extract_predicates( p, *expr.left());
......
...@@ -230,6 +230,7 @@ struct dve_compiler: public dve_explicit_system_t ...@@ -230,6 +230,7 @@ struct dve_compiler: public dve_explicit_system_t
bool split_conjunctive_expression(std::vector<guard>& guard, dve_expression_t* expr); bool split_conjunctive_expression(std::vector<guard>& guard, dve_expression_t* expr);
void merge_dependent_expression(std::vector<guard>& guard, int sv_count); void merge_dependent_expression(std::vector<guard>& guard, int sv_count);
void gen_transition_info(); void gen_transition_info();
bool get_const_varname( dve_expression_t & expr, string & var);
bool get_const_expression( dve_expression_t & expr, int & value); bool get_const_expression( dve_expression_t & expr, int & value);
bool is_guard_nes( guard& g, ext_transition_t& t ); bool is_guard_nes( guard& g, ext_transition_t& t );
bool may_be_coenabled( guard& ga, guard& gb); bool may_be_coenabled( guard& ga, guard& gb);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment