📄 logic_item.cc
字号:
/* HYSDEL Copyright (C) 1999-2002 Fabio D. Torrisi This file is part of HYSDEL. HYSDEL is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. HYSDEL is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA CONTACT INFORMATION =================== Fabio D. Torrisi ETH Zentrum Physikstrasse. 3 ETL, CH-8032 Zurich Switzerland mailto:torrisi@aut.ee.ethz.ch (preferred)*/#include "Logic_item.h"#include "CNF_clause.h"#include "Symbol_table.h"#include "MLD_representation.h"#include "Expr.h"#include "Equivalence_expr.h"#include "Variable_expr.h"#include "Var_symbol.h"//#include <stdlib.h>#include <stdio.h>#include "Globals.h"#include "Problem.h"#include "Problem_handler.h"Logic_item::Logic_item(const Var_symbol * var, Expr * log_expr, const Globals * glob) : Definition_item(var, glob) { assert(log_expr); //fine logic_expr = log_expr;}list < const Var_symbol * > Logic_item::get_required_mme() const { list < const Var_symbol * > req; return req;}list < const Var_symbol * > Logic_item::get_required_simu() const { list < const Var_symbol * > req; req = get_required_mme(); add_required(req, logic_expr); return req;}Logic_item::~Logic_item() { delete logic_expr; this->Definition_item::~Definition_item();}MLD_representation * Logic_item::translate_MLD() const { MLD_representation * mld; CNF_clause * cnf; Expr * equiv; int subind_cnt = 0; mld = new MLD_representation(globals); equiv = new Equivalence_expr( new Variable_expr(lhs_var, globals), logic_expr->clone()); cnf = equiv->compute_CNF(); cnf_to_mld(cnf, mld, & subind_cnt); delete cnf; return mld;}list < Item * > Logic_item::unroll() { list < Item * > unr; list < Item * >::iterator iter; unr = logic_expr->unroll(); for (iter = unr.begin(); iter != unr.end(); iter++) (* iter)->set_unrolled_from(this); return unr;}void Logic_item::semantic_checks() { string msg; char buf[20]; if (lhs_var->get_kind() != AUX_KIND) { sprintf(buf, "line %d: ", get_source_line()); msg = buf; msg += string("left hand side variable ") + lhs_var->get_name() + string(" is not auxiliary"); msg += string(" (") + lhs_var->get_name() + string(" declared at line "); sprintf(buf, "%d)", lhs_var->get_line_of_decl()); msg += string(buf); globals->problem_handler->process(new Problem(ERROR, msg)); } if (lhs_var->get_type() != BOOL_TYPE) { sprintf(buf, "line %d: ", get_source_line()); msg = buf; msg += string("left hand side variable ") + lhs_var->get_name() + string(" is not Boolean"); msg += string(" {") + lhs_var->get_name() + string(" declared at line "); sprintf(buf, "%d)", lhs_var->get_line_of_decl()); msg += string(buf); globals->problem_handler->process(new Problem(ERROR, msg)); } if (is_required_simu(lhs_var)) { sprintf(buf, "line %d: ", get_source_line()); msg = buf; msg += string("recursive definition of variable ") + lhs_var->get_name(); globals->problem_handler->process(new Problem(ERROR, msg)); } logic_expr->semantic_checks(); assert(logic_expr->is_logic()); //fine}string Logic_item::matlab_simu() const { string res; res += string("% ") + get_source() + string("\n"); res += lhs_var->to_matlab() + string(" = ") + logic_expr->to_matlab() + string(";\n"); res += string("\n"); return res;}string Logic_item::arg_range_check_matlab() const { string res; res += logic_expr->arg_range_check_matlab(); return res;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -