当前位置: 首页>>代码示例>>C++>>正文


C++ symbol_table类代码示例

本文整理汇总了C++中symbol_table的典型用法代码示例。如果您正苦于以下问题:C++ symbol_table类的具体用法?C++ symbol_table怎么用?C++ symbol_table使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了symbol_table类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: eval

fp_t ast_fun_call_expr::eval(symbol_table& sym)
{
  list<fp_t> args;
  for (auto _ex : *_exs)
    args.push_back(_ex->eval(sym));

  sym.open_scope();

  ptr<ast_fun_def> _fd = sym.get_fun_def(_id);
  
  auto arg_it = args.begin();
  for (auto _param_id : *(_fd->_ids))
    sym.set_var(_param_id, *arg_it++);

  maybe_fp_t ret = _fd->_bl->exec(sym);

  sym.close_scope();

  if (not ret.is_valid)
  {
    // runtime error
    cerr << MYLANGA_RUNTIME_ERROR << " | " << \
      "La función \'" << *_id << "\' se ejecutó sin retornar un valor." << endl;
    MYLANGA_END_ABRUPTLY();
  }

  return ret.value;
}
开发者ID:ealmansi,项目名称:tl-tp,代码行数:28,代码来源:mylanga_ast.cpp

示例2: traverse_block_two

/** Traverse block and find name of symbol */
static string traverse_block_two(symbol_table mymap,string tname){
  // find in map
  symbol_table::iterator got = mymap.find (&tname);

  // if symbool found, return symbol
  if ( got != mymap.end() ) {
    string type = *(got->first);
    return type;
  }

  // otherwise, keep traversing
  return traverse_block_two(*got->second->fields,tname);
}
开发者ID:isayyuhh-s,项目名称:ucsc-cs,代码行数:14,代码来源:symtable.cpp

示例3: is_valid

bool ast_fun_call_expr::is_valid(symbol_table& sym)
{
  bool res = true;

  do
  {
    ptr<ast_fun_def> _fd = sym.get_fun_def(_id);
    if (_fd == nullptr)
    {
      cerr << MYLANGA_PARSE_ERROR(_ln) << " | " << \
        "La función \'" << *_id << "\' no se encuentra definida." << endl;
      res = false; break;
    }

    if (_fd->_ids->size() != _exs->size())
    {
      cerr << MYLANGA_PARSE_ERROR(_ln) << " | " << \
        "La función " << (*(_fd->_id)) << " recibe " << to_string(_fd->_ids->size()) << \
        " parámetro(s), pero es invocada con " <<  to_string(_exs->size()) << \
        " argumento(s)." << endl;
      res = false; break;
    }
  } while (false);
  
  for (auto _ex : *_exs)
    res = _ex->is_valid(sym) and res;

  return res;
}
开发者ID:ealmansi,项目名称:tl-tp,代码行数:29,代码来源:mylanga_ast.cpp

示例4: m_value

cheat_parameter::cheat_parameter(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node &paramnode)
	: m_value(0)
{
	// read the core attributes
	m_minval = number_and_format(xml_get_attribute_int(&paramnode, "min", 0), xml_get_attribute_int_format(&paramnode, "min"));
	m_maxval = number_and_format(xml_get_attribute_int(&paramnode, "max", 0), xml_get_attribute_int_format(&paramnode, "max"));
	m_stepval = number_and_format(xml_get_attribute_int(&paramnode, "step", 1), xml_get_attribute_int_format(&paramnode, "step"));

	// iterate over items
	for (xml_data_node *itemnode = xml_get_sibling(paramnode.child, "item"); itemnode != NULL; itemnode = xml_get_sibling(itemnode->next, "item"))
	{
		// check for NULL text
		if (itemnode->value == NULL || itemnode->value[0] == 0)
			throw emu_fatalerror("%s.xml(%d): item is missing text\n", filename, itemnode->line);

		// check for non-existant value
		if (xml_get_attribute(itemnode, "value") == NULL)
			throw emu_fatalerror("%s.xml(%d): item is value\n", filename, itemnode->line);

		// extract the parameters
		UINT64 value = xml_get_attribute_int(itemnode, "value", 0);
		int format = xml_get_attribute_int_format(itemnode, "value");

		// allocate and append a new item
		item &curitem = m_itemlist.append(*global_alloc(item(itemnode->value, value, format)));

		// ensure the maximum expands to suit
		m_maxval = MAX(m_maxval, curitem.value());
	}

	// add a variable to the symbol table for our value
	symbols.add("param", symbol_table::READ_ONLY, &m_value);
}
开发者ID:jiangzhonghui,项目名称:mame,代码行数:33,代码来源:cheat.c

示例5: m_value

cheat_parameter::cheat_parameter(cheat_manager &manager, symbol_table &symbols, const char *filename, xml_data_node const &paramnode)
	: m_value(0)
{
	// read the core attributes
	m_minval = number_and_format(paramnode.get_attribute_int("min", 0), paramnode.get_attribute_int_format("min"));
	m_maxval = number_and_format(paramnode.get_attribute_int("max", 0), paramnode.get_attribute_int_format("max"));
	m_stepval = number_and_format(paramnode.get_attribute_int("step", 1), paramnode.get_attribute_int_format("step"));

	// iterate over items
	for (xml_data_node const *itemnode = paramnode.get_child("item"); itemnode != nullptr; itemnode = itemnode->get_next_sibling("item"))
	{
		// check for nullptr text
		if (itemnode->get_value() == nullptr || itemnode->get_value()[0] == 0)
			throw emu_fatalerror("%s.xml(%d): item is missing text\n", filename, itemnode->line);

		// check for non-existant value
		if (!itemnode->has_attribute("value"))
			throw emu_fatalerror("%s.xml(%d): item is value\n", filename, itemnode->line);

		// extract the parameters
		uint64_t const value = itemnode->get_attribute_int("value", 0);
		xml_data_node::int_format const format = itemnode->get_attribute_int_format("value");

		// allocate and append a new item
		auto curitem = std::make_unique<item>(itemnode->get_value(), value, format);

		// ensure the maximum expands to suit
		m_maxval = std::max(m_maxval, curitem->value());

		m_itemlist.push_back(std::move(curitem));
	}

	// add a variable to the symbol table for our value
	symbols.add("param", symbol_table::READ_ONLY, &m_value);
}
开发者ID:crazii,项目名称:mameui,代码行数:35,代码来源:cheat.cpp

示例6: parse_state

tree::node::ptr parse_state(std::string expr, std::string const& context, symbol_table symbol_table,
		const parser::parse_policy& ppol) {
	if (expr == "") {
		tree::node::ptr p = tree::node::ptr(tree::node::null_node());
		return p;
	} else {
		symbol_table.set_context(context);
		state_grammar g;
		state_ast my_ast;
		std::string::const_iterator iter = expr.begin();
		std::string::const_iterator end = expr.end();

		bool r = boost::spirit::qi::phrase_parse(iter, end, g, boost::spirit::ascii::space, my_ast);

		if (r && iter == end) {
			return make_state_tree(my_ast, symbol_table,ppol);
		} else {
			/**
			* error handle : precise as to when the parser fails
			* (part of the predicate fails)
			*/
			throw basic_exception("Could not parse predicate:\n" + expr + "\n" + std::string(iter-expr.begin(),' ') + "^"+ std::string(iter, end));
		}
	}
}
开发者ID:selyunin,项目名称:spcx-src,代码行数:25,代码来源:state_parser.cpp

示例7: operator

    tree::node_ptr operator()(state_loc const& pred) const {
		std::string autom(pred.aut);
		std::string context=my_symbol_table.get_context();
		if (autom == "") {
			autom = context;
			context = "";
		}

		return tree::node_ptr(hybrid_automata::location_node_creator::create(
				autom, context, pred.loc, pred.eq));
	}
开发者ID:selyunin,项目名称:spcx-src,代码行数:11,代码来源:state_parser.cpp

示例8: reset_patterns

void affineStatement::reset_patterns( const symbol_table& new_table )
{
	Datum * parent;
	AccessPattern * new_pat;
	symbol_table::const_iterator it;
	
	for ( int i = 0 ; i < Reads.size() ; i++ ) {
		parent = Reads[i]->get_parent();
		it = new_table.find(parent->get_name());
		new_pat = it->second.get_pattern(Reads[i]->get_id());
		Reads[i] = new_pat;
	}
	
	for ( int i = 0 ; i < Writes.size() ; i++ ) {
		parent = Writes[i]->get_parent();
		it = new_table.find(parent->get_name());
		new_pat = it->second.get_pattern(Writes[i]->get_id());
		Writes[i] = new_pat;
	}
}
开发者ID:8l,项目名称:rose,代码行数:20,代码来源:RosePollyModel.cpp

示例9: plot

void ast_plot_cmd::plot(symbol_table& sym)
{
  sym.open_scope();

  fp_t range_from = _ex1->eval(sym),
  range_step = _ex2->eval(sym),
  range_to = _ex3->eval(sym);

  for (fp_t x = range_from; x <= range_to; x += range_step)
  {
    sym.set_var(_id, x);

    fp_t x_value = _ex_x->eval(sym),
    y_value = _ex_y->eval(sym);

    cout << x_value << " " << y_value << endl;

  }

  sym.close_scope();
}
开发者ID:ealmansi,项目名称:tl-tp,代码行数:21,代码来源:mylanga_ast.cpp

示例10: search_for_access_patterns

void Statement::set_patterns( symbol_table& data )
{
	SgExpression * exp = myStatement->get_expression();
	IO lhsIO;
	vector<AccessPattern*> patList;
	
	if ( !isSgBinaryOp(exp) ) {
		if ( isSgUnaryOp(exp) )
			search_for_access_patterns( isSgUnaryOp(exp)->get_operand(), patList, INOUT );
		else
			report_error("Unrecognized expression statement",exp);

	} else {
		lhsIO = ( isSgAssignOp(exp) ) ? OUT : INOUT;

		/* Left hand side */
		search_for_access_patterns( isSgBinaryOp(exp)->get_lhs_operand(), patList, lhsIO );
		
		/* Right hand side */
		search_for_access_patterns( isSgBinaryOp(exp)->get_rhs_operand(), patList, IN );
	}
	
	for ( int i = 0 ; i < patList.size() ; i++ ) { 
		
		int dim = patList[i]->get_dim();
		SgExpression * exp = patList[i]->get_refExp();
		
		for ( int j = 0 ; j < dim ; j++ )
			exp = isSgPntrArrRefExp(exp)->get_lhs_operand();
		
		string ap_name = isSgVarRefExp(exp)->get_symbol()->get_name().getString();
		
		symbol_table::iterator it = data.find(ap_name);
		it->second.add_pattern(patList[i]);
		add_pattern(patList[i]);
	}
}
开发者ID:8l,项目名称:rose,代码行数:37,代码来源:Nodes.cpp

示例11: lookup_string

 symbol_data lookup_string(const char * str, std::size_t length)
 {
     static symbol_table table;
     return table.find(str, length);
 }
开发者ID:8c6794b6,项目名称:supercollider,代码行数:5,代码来源:named_hash_entry.hpp

示例12: exec

maybe_fp_t ast_var_assign_stmt::exec(symbol_table& sym)
{
  sym.set_var(_id, _ex->eval(sym));

  return maybe_fp_t();
}
开发者ID:ealmansi,项目名称:tl-tp,代码行数:6,代码来源:mylanga_ast.cpp

示例13: find_typeTable

symbol* find_typeTable (const string* key) {
  auto found = typeTable.find(key);
  if (found == typeTable.end()){
    return NULL;
  } else {
    return found->second;
  }
}
开发者ID:zero14777,项目名称:My-Stuff,代码行数:8,代码来源:symboltable.cpp

示例14: grabStructSymbol

symbol* grabStructSymbol (const string* ident)
{
  auto table_check = typeTable.find(ident);
  if(table_check != typeTable.end())
    {
      return table_check->second;
    }
  fprintf(stderr, "oc: %s struct does not exist\n", ident->c_str());
  return NULL;
}
开发者ID:zero14777,项目名称:My-Stuff,代码行数:10,代码来源:symboltable.cpp

示例15: table_dump

// print out the items stored in the two tables
void table_dump () {
   printf("Identifiers:\n");
   int ident_scp = 0;
   for (auto v: idents) {
      printf("%d\n", ident_scp);
      for (auto i = v->cbegin(); i != v->cend(); i++) {
         printf("\t %s %s\n", i->first->c_str(),
         get_attributes(i->second->attributes));
      }
      ident_scp++;
   }
   printf("Types:\n");
   for (auto i = types.cbegin(); i != types.cend(); i++) {
      printf("%s\n", i->first->c_str());
      for (auto j = i->second->fields->cbegin();
            j != i->second->fields->cend(); j++) {
         printf("\t%s %s\n", j->first->c_str(),
         get_attributes(j->second->attributes));
      }
   }
}
开发者ID:FrankieFabuloso,项目名称:CMPS104_CompilerDesign,代码行数:22,代码来源:typechecker.cpp


注:本文中的symbol_table类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。