📄 cont_output_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 "Cont_output_item.h"#include "Var_symbol.h"#include "Expr.h"#include "Affine_func.h"#include "Symbol_table.h"#include "MLD_representation.h"#include "Cmd_options.h"#include "Linear_item.h"#include "Affine_addend.h"#include "Variable_expr.h"#include "Plus_expr.h"#include <stdio.h>#include "Globals.h"#include "Problem.h"#include "Problem_handler.h"Cont_output_item::Cont_output_item(const Var_symbol * lhs, Expr * e, const Globals * glob) : Output_item(lhs, glob) { affine_expr = e;}list < const Var_symbol * > Cont_output_item::get_required_simu() const { list < const Var_symbol * > req; add_required(req, affine_expr); return req;}Cont_output_item::~Cont_output_item() { delete affine_expr; this->Definition_item::~Definition_item();}list < Item * > Cont_output_item::unroll() { Item * cnst_item = NULL; list < Item * > res; list < Item * >::iterator iter; Expr * lin_expr; if (globals->cmd_options->consts_in_eq_as_auxvar()) { cnst_item = extract_const_from_aff(affine_expr, & lin_expr); delete affine_expr; affine_expr = lin_expr; } if (globals->cmd_options->consts_in_eq_as_error()) { Affine_func *aff; aff = affine_expr->compute_affine(); if (aff->find_addend(NULL)) { // there is a constant term string msg; char buf[20]; sprintf(buf, "line %d: ", get_source_line()); msg = buf; msg += string("constant term in OUTPUT"); globals->problem_handler->process( new Problem(ERROR, msg)); } delete aff; } res = affine_expr->unroll(); if (cnst_item) res.push_back(cnst_item); for (iter = res.begin(); iter != res.end(); iter++) { (* iter)->set_unrolled_from(this); } return res;}MLD_representation * Cont_output_item::translate_MLD() const { MLD_representation * mld; Affine_func * aff; int subind_cnt = 0; mld = new MLD_representation(globals); aff = affine_expr->compute_affine(); aff_to_mld_eq(lhs_var, aff, mld, & subind_cnt); delete aff; return mld;}void Cont_output_item::semantic_checks() { string msg; char buf[20]; if (lhs_var->get_kind() != OUTPUT_KIND) { sprintf(buf, "line %d: ", get_source_line()); msg = buf; msg += string("left hand side variable ") + lhs_var->get_name() + string(" is not output"); 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() != REAL_TYPE) { sprintf(buf, "line %d: ", get_source_line()); msg = buf; msg += string("left hand side variable ") + lhs_var->get_name() + string(" is not real"); 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)); } affine_expr->semantic_checks(); if (!affine_expr->is_affine()) { sprintf(buf, "line %d: ", get_source_line()); msg = buf; msg += string("expression must be affine"); globals->problem_handler->process(new Problem(ERROR, msg)); }}string Cont_output_item::matlab_simu() const { string res; res += string("% ") + get_source() + string("\n"); res += lhs_var->to_matlab() + string(" = ") + affine_expr->to_matlab() + string(";\n"); res += string("\n"); return res;}string Cont_output_item::arg_range_check_matlab() const { string res; res += affine_expr->arg_range_check_matlab(); return res;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -