⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 binary_expr.cc

📁 由matlab开发的hybrid系统的描述语言
💻 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 "Binary_expr.h"#include "Globals.h"#include "Cmd_options.h"#include "Number_expr.h"/** maybe use a copy of l and r, so these could be modified afterwards */Binary_expr::Binary_expr(Expr * l, Expr * r) : Expr(l) {	left = l;	right = r;}Binary_expr::~Binary_expr() {	delete left;	delete right;}Expr * Binary_expr::clone() const {	Binary_expr * n;	n = (Binary_expr *) shallow_copy();	n->left = left->clone();	n->right = right->clone();	n->globals = globals;	n->source_line = source_line;	n->source = source;	return n;}string Binary_expr::to_matlab() const {	string s;	if (globals->cmd_options->all_params_symbolic() || !is_number() ) {	  s += "(";	  s += left->to_matlab();	  s +=")";	  s += string(" ") + this->symbol_str() + string(" ");	  s +="(";	  s += right->to_matlab();	  s += ")";	} else {	  Number *n;	  n=compute_number();	  s += n->to_matlab();	  delete n;	}	return s;}bool Binary_expr::is_const() const {	return left->is_const() && right->is_const();}bool Binary_expr::is_real() const {	return left->is_real() && right->is_real();}bool Binary_expr::is_logic() const {	return left->is_logic() && right->is_logic();}bool Binary_expr::is_symbolic() const {	return left->is_symbolic() || right->is_symbolic();}list < Item * > Binary_expr::unroll() {	list < Item * > l, r;	l = left->unroll();	r = right->unroll();	l.insert(l.end(), r.begin(), r.end());	return l;}string Binary_expr::arg_range_check_matlab() const {	string res;	res += left->arg_range_check_matlab();	res += right->arg_range_check_matlab();	return res;} void Binary_expr::simplify() {  Expr *tmp;  if (!globals->cmd_options->all_params_symbolic()) {    if (left->is_number()) {      tmp=left;      left=new Number_expr(left->compute_number(), globals);      delete tmp;    }    if (right->is_number()) {      tmp=right;      right=new Number_expr(right->compute_number(), globals);      delete tmp;    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -