Пример #1
0
// Create netlist and output as a SPICE file
void CNetList::WriteSpiceFile( CTinyCadMultiDoc *pDesign, const TCHAR *filename )
{
	// Open the filename for the spice file
	FILE *theFile;
	errno_t err;
	err = _tfopen_s(&theFile, filename,_T("w"));
	if ((theFile == NULL) || (err != 0))
	{
		Message(IDS_CANNOTOPEN);
		return;
	}

	// Output the standard header comment - expected on line 1 by some Spice engines
	_ftprintf(theFile,_T("* Schematics Netlist *\n"));

	createErrorFile( filename );

	_ftprintf(m_err_file,_T("Results of Spice file generation for %s\n\n"),
		pDesign->GetPathName() );


	// Set the Busy icon
	SetCursor( AfxGetApp()->LoadStandardCursor( IDC_WAIT ) );

	// Create the net list
	m_prefix_import = TRUE;
	m_prefix_references = TRUE;
	MakeNet( pDesign );

	
	// Now we have the net list we must convert it into a file suitable for
	// spice...
	//
	// The netlist represents a single vector per net, however, spice requires
	// a vector per symbol.  We have to rotate the array, so that we have one
	// entry in our vector for each of the symbols in our drawing....
	//
	
	typedef std::map<CString,CNetListSymbol>	symbolCollection;
	symbolCollection symbols;
	labelCollection labels;


	netCollection::iterator nit = m_nets.begin();

	while (nit != m_nets.end()) 
	{
		nodeVector::iterator nv_it = (*nit).second.begin();

		while (nv_it != (*nit).second.end()) 
		{
			CNetListNode& theNode = *nv_it;
			++ nv_it;

			// Is this node a symbol?
			if (!theNode.m_reference.IsEmpty() && theNode.m_pMethod->GetType() == xMethodEx3 )
			{
				// Yes, so update the pin allocations in the symbol map...
				CNetListSymbol &symbol = symbols[ theNode.m_reference ];

				symbol.m_pins[ theNode.m_pin ] = theNode.m_NetList;
				symbol.m_pMethod = theNode.m_pMethod;
			}

			// Is this node a label?
			if (!theNode.getLabel().IsEmpty())
			{
				// Yes, so update the label collection
				labels[ theNode.m_NetList ] = theNode.getLabel();
			}
		}

		++ nit;
	}


	//
	// We scan the symbols array and extract any file imports
	// That we need from the fields of the symbols...
	//
	symbolCollection::iterator sit = symbols.begin();

	typedef std::set<CString> strings;
	typedef std::vector<strings> string_collection;
	string_collection prolog_lines;
	string_collection epilog_lines;
	prolog_lines.resize( 10 );
	epilog_lines.resize( 10 );

	// Do this for all of the files in the imports list...
	fileCollection::iterator fi = m_imports.begin();
	for (;fi != m_imports.end(); ++ fi)
	{
		CTinyCadMultiDoc *dsn = pDesign;

		if ((*fi)->m_file_name_index != 0)
		{
			dsn = (*fi)->m_pDesign;
		}

		// Generate a component for every sheet in this design
		for (int sheet = 0; sheet < dsn->GetNumberOfSheets(); sheet++)
		{
			drawingIterator it = dsn->GetSheet(sheet)->GetDrawingBegin();
			while (it != dsn->GetSheet(sheet)->GetDrawingEnd()) 
			{
				CDrawingObject *pointer = *it;

				if (pointer->GetType() == xMethodEx3) 
				{
					CDrawMethod *pMethod = static_cast<CDrawMethod *>(pointer);

					// Search this symbols fields and extract the SPICE_IMPORT field...
					//

					CString spice_prolog;
					CString spice_epilog;
					int spice_pro_priority = 5;
					int spice_epi_priority = 5;

					for (int j = 0; j < pMethod->GetFieldCount(); j++)
					{
						CString field = pMethod->GetFieldName(j);
						if (field.CompareNoCase(AttrSpiceProlog) == 0)
						{
							CNetListSymbol symbol( (*fi)->m_file_name_index, sheet, pMethod );
							spice_prolog = expand_spice( (*fi)->m_file_name_index, sheet, symbol, labels, pMethod->GetField(j) );
						}
						else if (field.CompareNoCase(AttrSpiceEpilog) == 0)
						{
							CNetListSymbol symbol( (*fi)->m_file_name_index, sheet, pMethod );
							spice_epilog = expand_spice( (*fi)->m_file_name_index, sheet, symbol, labels, pMethod->GetField(j) );
						}
						else if (field.CompareNoCase(AttrSpicePrologPri) == 0)
						{
							spice_pro_priority = _tstoi( pMethod->GetField(j) );
							if (spice_pro_priority < 0 || spice_pro_priority > 9)
							{
								spice_pro_priority = 5;
							}
						}
						else if (field.CompareNoCase(AttrSpiceEpilogPri) == 0)
						{
							spice_epi_priority = _tstoi( pMethod->GetField(j) );
							if (spice_epi_priority < 0 || spice_epi_priority > 9)
							{
								spice_epi_priority = 5;
							}
						}
					}


					// Prologue...
					strings &prolog = prolog_lines[ spice_pro_priority ];
					if (prolog.find( spice_prolog ) == prolog.end())
					{
						// Not included yet...
						prolog.insert( spice_prolog );
					}

					// Epilog..
					strings &epilog = epilog_lines[ spice_pro_priority ];
					if (epilog.find( spice_epilog ) == epilog.end())
					{
						// Not included yet...
						epilog.insert( spice_epilog );
					}
				}
			
				++ it;
			}
		}
	}
 
	// We have extracted the prologue, so now output it in the
    // order of priority (0 being first...)
	int priority;
    for (priority = 0; priority < 10; priority ++)
	{
		strings &s = prolog_lines[ priority ];
		strings::iterator i = s.begin();
		while (i != s.end())
		{
			_ftprintf( theFile, _T("%s\n"), *i );
			++ i;
		}
	}


	// We now have the netlist in the form we require it, so
	// let us now output the symbols in the correct SPICE format...
	//
	sit = symbols.begin();
	while (sit != symbols.end())
	{
		CString reference = (*sit).first;
		CNetListSymbol &symbol = (*sit).second;
		CDrawMethod* pMethod = symbol.m_pMethod;
		int sheet = symbol.m_sheet;
		int file_name_index = symbol.m_file_name_index;

		// Here is the data we are going to extract from
		// the symbol's fields...
		CString spice = "";

		// Search this symbols fields and extract the SPICE field...
		//
		int i;
		for (i = 0; i < pMethod->GetFieldCount(); i++)
		{
			if (pMethod->GetFieldName(i).CompareNoCase(AttrSpice) == 0)
			{
				spice = pMethod->GetField(i);
			}
		}

		
		// Now output the SPICE model line
		if (!spice.IsEmpty())
		{
			_ftprintf(theFile,_T("%s\n"), expand_spice( file_name_index, sheet, symbol, labels, spice ) );
		}
		else
		{
			_ftprintf(theFile,_T("NO_MODEL\n") );
			writeError(_T("%s: %s on sheet %d has no model\n"),
				symbol.m_pMethod->GetRef(), symbol.m_pMethod->GetName(), sheet );
		}
		++ sit;
	}


	// Now write out the epilog
    for (priority = 9; priority >= 0; priority --)
	{
		strings &s = epilog_lines[ priority ];
		strings::iterator i = s.begin();
		while (i != s.end())
		{
			_ftprintf( theFile,_T("%s\n"), *i );
			++ i;
		}
	}



	SetCursor( AfxGetApp()->LoadStandardCursor( IDC_ARROW ) );
	fclose(theFile);

	reopenErrorFile( true );
}
Пример #2
0
SymbolSlab generateSymbols(std::vector<std::string> QualifiedNames) {
  SymbolSlab::Builder Slab;
  for (llvm::StringRef QName : QualifiedNames)
    Slab.insert(symbol(QName));
  return std::move(Slab).build();
}
Пример #3
0
/*!
** this code should be read as table of generic cases (where row/column doesn't matter)
** which is important for the graphicsView. for the treeView there is a part of code where
** row/column matters, see the very long switch statement.
*/
QVariant Model::data( const QModelIndex &index, int role ) const {
//   qDebug() << __FUNCTION__;
  if ( !index.isValid() )
    return QVariant();

  AbstractTreeItem* n = static_cast<AbstractTreeItem*>( index.internalPointer() );
  if ( role == customRole::CustomLabelRole )
    return n->getProperty( "CustomLabelRole" );
  // to understand customRole::TypeRole see the comment (Model.h - TreeItemType enum comment )
  if ( role == customRole::TypeRole ) {
    if ( n->getObjectType() == AUTOMATE_ROOT )
      return ViewTreeItemType::AUTOMATE_ROOT;
    if ( n->getObjectType() == NODE_CONNECTION )
      return ViewTreeItemType::NODE_CONNECTION;
    if ( n->getObjectType() == NODE )
      return ViewTreeItemType::NODE;
    return ViewTreeItemType::UNKNOWN;
  }
  if ( role == customRole::FinalRole )
    if ( n->getObjectType() == NODE )
      return n->getProperty( "final" );
  if ( role == customRole::PosRole )
    if ( n->getObjectType() == NODE )
      return n->getProperty( "pos" );
  if ( role == customRole::StartRole )
    if ( n->getObjectType() == NODE )
      return n->getProperty( "start" );
  if ( role == customRole::SymbolIndexRole )
    if ( n->getObjectType() == NODE_CONNECTION ) {
      node_connection* nc = static_cast<node_connection*>( index.internalPointer() );
//       qDebug() << __FUNCTION__ << symbol( nc->symbol_index ) << nc->symbol_index;
      return symbol( nc->symbol_index() ) ;
    }
  if ( role == customRole::IdRole )
    if ( n->getObjectType() == NODE || n->getObjectType() == NODE_CONNECTION )
      return n->getId();
  switch ( index.column() ) {
  case 0:
    switch ( role ) {
    case Qt::DecorationRole:
      if ( n->getObjectType() == NODE )
        return QIcon( ":/icons/node.png" );
      if ( n->getObjectType() == NODE_CONNECTION )
        return QIcon( ":/icons/connect.png" );
    }
    break;
  case 1:
    switch ( role ) {
    case Qt::ToolTipRole:
      break;
    case Qt::WhatsThisRole:
      break;
    case Qt::TextAlignmentRole:
//           if (index.column() == 1)
//             return Qt::AlignHCenter;
//           if (index.column() == 2)
//             return Qt::AlignHCenter;
      break;
    case customRole::SortRole:
    case Qt::DecorationRole:
      if ( n->getObjectType() == NODE ) {
        if ( n->getProperty( "start" ).toBool() ) {
          if ( role == customRole::SortRole )
            return 1;
          return QIcon( ":/icons/startNode.png" );
        } else {
          if ( role == customRole::SortRole )
            return 0;
        }
      }
      break;
//     case Qt::BackgroundRole:
//       break;
    }
    break;
  case 2:
    switch ( role ) {
    case customRole::SortRole:
    case Qt::DecorationRole:
      if ( n->getObjectType() == NODE ) {
        if ( n->getProperty( "final" ).toBool() ) {
          if ( role == customRole::SortRole )
            return 1;
          return QIcon( ":/icons/finalNode.png" );
        } else {
          if ( role == customRole::SortRole )
            return 0;
        }
      }
      break;
    }
    break;
  case 3:
    switch ( role ) {
    case customRole::SortRole:
    case Qt::DisplayRole:
      if ( n->getObjectType() == NODE ) {
        if ( role == customRole::SortRole ) {
          return n->getId();
        }
        if ( role == Qt::DisplayRole )
          return QString( "n%1" ).arg( n->getId() );// "node";
      }
      if ( n->getObjectType() == NODE_CONNECTION ) {
        if ( role == customRole::SortRole )
          return n->getId();
        if ( role == Qt::DisplayRole )
          return QString( "c%1" ).arg( n->getId() );// "node_connection";
      }
      break;
    }
  case 4:
    switch ( role ) {
    case customRole::SortRole:
    case Qt::DisplayRole:
      if ( n->getObjectType() == NODE_CONNECTION ) {
        if ( role == customRole::SortRole )
          return ( static_cast<node_connection*>( n ) )->symbol_index();// "node_connection";
        if ( role == Qt::DisplayRole )
          return symbol(( static_cast<node_connection*>( n ) )->symbol_index() );// "node_connection";
      }
    }

    break;
  case 5:
    switch ( role ) {
    case Qt::BackgroundRole:
      if ( n->getObjectType() == NODE_CONNECTION )
        if ((static_cast<node_connection*>( n ) )->next_node() == NULL)
          return QBrush( QColor( 255, 0, 0, 250 ) );
      break;
    case customRole::SortRole:
    case Qt::DisplayRole:
      if ( n->getObjectType() == NODE_CONNECTION ) {
        if ((static_cast<node_connection*>( n ) )->next_node() == NULL)
          return "undefined";
        AbstractTreeItem* next_node = ( static_cast<node_connection*>( n ) )->next_node();
        if ( role == customRole::SortRole )
          return next_node->getId();// "node_connection";
        if ( role == Qt::DisplayRole )
          return QString( "n%1" ).arg( next_node->getId() );// "node_connection";
      }
    }
    break;
  case 6:
    if ( role == Qt::DisplayRole ) {
      return n->getProperty( "CustomLabelRole" );
    }
    break;
    /*  case 7:
        break;*/
  }
  if ( role == Qt::BackgroundRole ) {
    if ( n->getObjectType() == NODE )
      return QBrush( QColor( 50, 160, 170, 150 ) );
    if ( n->getObjectType() == NODE_CONNECTION )
      return QBrush( QColor( 180, 200, 200, 50 ) );
  }

  return QVariant();
}
Пример #4
0
 symbol dimension (const Scope&) const 
 {     
   daisy_assert (state != uninitialized);
   return symbol (source->dimension ());
 }
Пример #5
0
void bv_elim::elim(quantifier* q, quantifier_ref& r) {

    svector<symbol>  names, _names;
    sort_ref_buffer  sorts(m_manager), _sorts(m_manager);
    expr_ref_buffer  pats(m_manager);
    expr_ref_buffer  no_pats(m_manager);
    expr_ref_buffer  subst_map(m_manager), _subst_map(m_manager);
    var_subst        subst(m_manager);
    bv_util          bv(m_manager);
    expr_ref         new_body(m_manager);
    expr*            old_body = q->get_expr();
    unsigned num_decls = q->get_num_decls();
    family_id bfid = m_manager.get_family_id("bv");

    //
    // Traverse sequence of bound variables to eliminate
    // bit-vecctor variables and replace them by 
    // Booleans.
    // 
    unsigned var_idx = 0;
    for (unsigned i = num_decls; i > 0; ) {
        --i;
        sort*  s  = q->get_decl_sort(i);
        symbol nm = q->get_decl_name(i);

        if (bv.is_bv_sort(s)) {
            // convert n-bit bit-vector variable into sequence of n-Booleans.
            unsigned num_bits = bv.get_bv_size(s);
            expr_ref_buffer args(m_manager);
            expr_ref bv(m_manager);
            for (unsigned j = 0; j < num_bits; ++j) {
                std::ostringstream new_name;
                new_name << nm.str();
                new_name << "_";
                new_name << j;
                var* v = m_manager.mk_var(var_idx++, m_manager.mk_bool_sort());                
                args.push_back(v);
                _sorts.push_back(m_manager.mk_bool_sort());
                _names.push_back(symbol(new_name.str().c_str()));
            }
            bv = m_manager.mk_app(bfid, OP_MKBV, 0, 0, args.size(), args.c_ptr());
            _subst_map.push_back(bv.get());
        }
        else {
            _subst_map.push_back(m_manager.mk_var(var_idx++, s));
            _sorts.push_back(s);
            _names.push_back(nm);
        }
    }
    // 
    // reverse the vectors.
    // 
    SASSERT(_names.size() == _sorts.size());
    for (unsigned i = _names.size(); i > 0; ) {
        --i;
        names.push_back(_names[i]);
        sorts.push_back(_sorts[i]);
    }
    for (unsigned i = _subst_map.size(); i > 0; ) {
        --i;
        subst_map.push_back(_subst_map[i]);
    }

    expr* const* sub  = subst_map.c_ptr();
    unsigned sub_size = subst_map.size();

    subst(old_body, sub_size, sub, new_body);

    for (unsigned j = 0; j < q->get_num_patterns(); j++) {
        expr_ref pat(m_manager);        
        subst(q->get_pattern(j), sub_size, sub, pat);
        pats.push_back(pat);
    }
    for (unsigned j = 0; j < q->get_num_no_patterns(); j++) {
        expr_ref nopat(m_manager);
        subst(q->get_no_pattern(j), sub_size, sub, nopat);
        no_pats.push_back(nopat);
    }

    r = m_manager.mk_quantifier(true, 
                                names.size(),
                                sorts.c_ptr(),
                                names.c_ptr(),
                                new_body.get(),
                                q->get_weight(),
                                q->get_qid(),
                                q->get_skid(),
                                pats.size(), pats.c_ptr(),
                                no_pats.size(), no_pats.c_ptr());
}
Пример #6
0
void
yybesselj(void)
{
	double d;
	int n;

	N = pop();
	X = pop();

	push(N);
	n = pop_integer();

	// numerical result

	if (isdouble(X) && n != (int) 0x80000000) {
		//d = jn(n, X->u.d);
		push_double(d);
		return;
	}

	// bessej(0,0) = 1

	if (iszero(X) && iszero(N)) {
		push_integer(1);
		return;
	}

	// besselj(0,n) = 0

	if (iszero(X) && n != (int) 0x80000000) {
		push_integer(0);
		return;
	}

	// half arguments

	if (N->k == NUM && MEQUAL(N->u.q.b, 2)) {

		// n = 1/2

		if (MEQUAL(N->u.q.a, 1)) {
			push_integer(2);
			push_symbol(PI);
			divide();
			push(X);
			divide();
			push_rational(1, 2);
			power();
			push(X);
			sine();
			multiply();
			return;
		}

		// n = -1/2

		if (MEQUAL(N->u.q.a, -1)) {
			push_integer(2);
			push_symbol(PI);
			divide();
			push(X);
			divide();
			push_rational(1, 2);
			power();
			push(X);
			cosine();
			multiply();
			return;
		}

		// besselj(x,n) = (2/x) (n-sgn(n)) besselj(x,n-sgn(n)) - besselj(x,n-2*sgn(n))

		push_integer(MSIGN(N->u.q.a));
		SGN = pop();

		push_integer(2);
		push(X);
		divide();
		push(N);
		push(SGN);
		subtract();
		multiply();
		push(X);
		push(N);
		push(SGN);
		subtract();
		besselj();
		multiply();
		push(X);
		push(N);
		push_integer(2);
		push(SGN);
		multiply();
		subtract();
		besselj();
		subtract();

		return;
	}


	push(symbol(BESSELJ));
	push(X);
	push(N);
	list(3);
}
Пример #7
0
void D_symbol(const SYMBOL *Symb, double x0, double y0,
	      const RGBA_Color *line_color,
	      const RGBA_Color *fill_color)
{
    symbol(Symb, x0, y0, fill_color, line_color, line_color);
}
Пример #8
0
int main(int argc, char *argv[])
{
    struct thread *thread;
    enum pause_reason reason;
    struct variable *var;
#if ! NO_ARGV_0
    char *argv0 = "mindy";
#endif

    exec_file_name = argv[0];

    init_color(false);

    init();

    thread = thread_make(symbol("main"));
    *thread->sp++ = make_raw_function("startup", obj_Nil,
                                      true, obj_False, false,
                                      obj_Nil, obj_ObjectClass,
                                      startup);

    while (*++argv != NULL) {
        if (strcmp(*argv, "-f") == 0) {
            if (*++argv == NULL)
                missing_arg("-f");
            load(*argv);
#if ! NO_SHARP_BANG
        } else if (strcmp(*argv, "-x") == 0) {
            if (*++argv == NULL)
                missing_arg("-f");
#if ! NO_ARGV_0
            if (strcmp(*argv, "-") != 0)
                argv0 = *argv;
#endif
            load(*argv);
            argv += 1;
            break;
#endif
#if ! NO_ARGV_0
        } else if (strcmp(*argv, "-0") == 0) {
            if (*++argv == NULL)
                missing_arg("-0");
            argv0 = *argv;
#endif
        } else {
            break;
        }
    }

#if ! NO_ARGV_0
        *thread->sp++ = make_byte_string(argv0);    /* pass command name */
#endif
    while (*argv != NULL)
        *thread->sp++ = make_byte_string(*argv++);

    finalize_modules();

    while (1) {
        thread_restart(thread);

        reason = do_stuff();
        if (reason != pause_NothingToRun)
            invoke_debugger(reason);

        var = find_variable(module_BuiltinStuff, symbol("exit"),
                            false, false);
        if (var == NULL)
            lose("main undefined?");

        thread = thread_make(symbol("exit"));
        *thread->sp++ = var->value;
    }
    return 0;
}
Пример #9
0
///////////////////////////////
// FIXME - make it loop over 
//   - eval_ast
//   - apply
// 
ast
EVAL (ast tree, environment::ptr a_env)
{
  for (;;)
  {
    if (!tree)
      return tree;

    if (tree->type () != node_type_enum::LIST)
      return eval_ast (tree, a_env);

    // not as_or_throw - we know the type
    auto root_list = tree->as<ast_node_list> ();
    if (root_list->empty ())
      return tree;

    //
    auto fn_handle_def = [root_list, &a_env]()
    {
      if (root_list->size () != 3)
        raise<mal_exception_eval_invalid_arg> (root_list->to_string ());

      const auto& key = (*root_list)[1]->as_or_throw<ast_node_symbol, mal_exception_eval_invalid_arg> ()->symbol ();

      ast_node::ptr value = EVAL ((*root_list)[2], a_env);
      a_env->set (key, value);
      return value;
    };

    // tco
    auto fn_handle_let_tco = [root_list, &a_env]() -> tco
    {
      if (root_list->size () != 3)
        raise<mal_exception_eval_invalid_arg> (root_list->to_string ());

      const ast_node_container_base* let_bindings = nullptr;
      const auto root_list_arg_1 = (*root_list)[1];
      switch (root_list_arg_1->type ())
      {
      case node_type_enum::LIST:
      case node_type_enum::VECTOR:
        let_bindings = root_list_arg_1->as<ast_node_container_base> ();
        break;
      default:
        raise<mal_exception_eval_invalid_arg> (root_list_arg_1->to_string ());
      };

      //
      auto let_env = environment::make (a_env);

      if (let_bindings->size () % 2 != 0)
        raise<mal_exception_eval_invalid_arg> (let_bindings->to_string ());
      
      for (size_t i = 0, e = let_bindings->size(); i < e; i += 2)
      {
        const auto& key = (*let_bindings)[i]->as_or_throw<ast_node_symbol, mal_exception_eval_invalid_arg> ()->symbol ();
        ast_node::ptr value = EVAL ((*let_bindings)[i + 1], let_env);

        let_env->set (key, value);
      }

      return {(*root_list)[2], let_env};
    };

    // tco
    auto fn_handle_apply_tco= [&tree, &a_env]() -> tco
    {
      ast_node::ptr new_node = eval_ast (tree, a_env);
      auto callable_list = new_node->as_or_throw<ast_node_list, mal_exception_eval_not_list> ();

      const size_t list_size = callable_list->size ();
      if (list_size == 0)
        raise<mal_exception_eval_not_callable> (callable_list->to_string ());

      auto && callable_node = (*callable_list)[0]->as_or_throw<ast_node_callable, mal_exception_eval_not_callable> ();

      return callable_node->call_tco (call_arguments (callable_list, 1, list_size - 1));
    };

    // tco
    auto fn_handle_do_tco = [root_list, &a_env]() -> tco
    {
      const size_t list_size = root_list->size ();
      if (list_size < 2)
        raise<mal_exception_eval_invalid_arg> (root_list->to_string ());

      for (size_t i = 1, e = list_size - 1; i < e; ++i)
      {
        /*retVal = */EVAL ((*root_list)[i], a_env);
      }

      return {(*root_list)[list_size - 1], a_env};
    };

    // tco
    auto fn_handle_if_tco = [root_list, &a_env] () -> tco
    {
      const size_t list_size = root_list->size ();
      if (list_size < 3 || list_size > 4)
        raise<mal_exception_eval_invalid_arg> (root_list->to_string ());

      ast_node::ptr condNode = EVAL ((*root_list)[1], a_env);
      const bool cond = !(condNode == ast_node::nil_node) && !(condNode == ast_node::false_node);

      if (cond)
        return {(*root_list)[2], a_env};
      else if (list_size == 4)
        return {(*root_list)[3], a_env};

      return tco {nullptr, nullptr, ast_node::nil_node};
    };

    auto fn_handle_fn = [root_list, &a_env] () -> ast
    {
      const size_t list_size = root_list->size ();
      if (list_size != 3)
        raise<mal_exception_eval_invalid_arg> (root_list->to_string ());

      auto&& bindsNode = (*root_list)[1];
      auto&& astNode = (*root_list)[2];

      ast_node::ptr retVal = std::make_shared<ast_node_callable_lambda> (bindsNode, astNode, a_env);
      return retVal;
    };

    auto first = (*root_list)[0];
    if (first->type () == node_type_enum::SYMBOL)
    {
      // apply special symbols
      // not as_or_throw - we know the type
      const auto first_symbol = first->as<ast_node_symbol> ();
      const auto& symbol = first_symbol->symbol ();

      if (symbol == "def!")
      {
        return fn_handle_def ();
      }
      else if (symbol == "let*")
      {
        std::tie (tree, a_env, std::ignore) = fn_handle_let_tco ();
        continue;
      }
      else if (symbol == "do")
      {
        std::tie (tree, a_env, std::ignore) = fn_handle_do_tco ();
        continue;
      }
      else if (symbol == "if")
      {
        ast retVal;
        std::tie (tree, a_env, retVal) = fn_handle_if_tco ();
        if (retVal)
          return retVal;
        continue;
      }
      else if (symbol == "fn*")
      {
        return fn_handle_fn ();
      }
    }

    // apply
    {
      ast retVal;
      std::tie (tree, a_env, retVal) = fn_handle_apply_tco ();
      if (retVal)
        return retVal;
      continue;
    }

  }
}
Пример #10
0
void smt2_parsert::operator()()
{
  char ch;
  unsigned open_parentheses=0;

  while(in.get(ch))
  {
    switch(ch)
    {
    case ' ':
    case '\n':
    case '\r':
    case '\t':
      // skip any whitespace
      break;
    
    case ';': // comment
      // skip until newline
      while(in.get(ch) && ch!='\n')
        ; // ignore
      break;
    
    case '(':
      // produce sub-expression
      open_parentheses++;
      open_expression();
      break;
      
    case ')':
      // done with sub-expression
      if(open_parentheses==0) // unexpected ')'. This is an error;
        return;
      
      open_parentheses--;

      close_expression();
      
      if(open_parentheses==0)
        return; // done        

      break;
      
    case '|': // quoted symbol
      get_quoted_symbol();
      symbol();
      if(open_parentheses==0) return; // done
      break;
      
    case '"': // string literal
      get_string_literal();
      symbol();
      if(open_parentheses==0) return; // done
      break;

    default: // likely a simple symbol
      get_simple_symbol(ch);
      symbol();
      if(open_parentheses==0) return; // done
    }
  }

  if(open_parentheses==0)
  {  
    // Hmpf, eof before we got anything. Blank file!
  }
  else
  {
    // Eof before end of expression. Error!
  }
}
Пример #11
0
 ---------
 	2002-02-08 : First version
 	2002-02-20 : New description of the API, non recursive lmap and reverse
 	2002-03-29 : Added function remElement(e,set), corrected comment error
	
******************************************************************************
*****************************************************************************/

#include <stdlib.h>
#include "list.hh"
#include "compatibility.hh"
#include <map>
#include <cstdlib>

// predefined symbols CONS and NIL
Sym CONS = symbol("cons");
Sym NIL  = symbol("nil");

// predefined nil tree
Tree nil = tree(NIL);


//------------------------------------------------------------------------------
// Printing of trees with special case for lists
//------------------------------------------------------------------------------

static bool printlist (Tree l, FILE* out)
{
	if (isList(l)) {
		
		char sep = '(';
Пример #12
0
Tree boxIdent(const char* name)		{ return tree(BOXIDENT, tree(symbol(name)) ); }
Пример #13
0
 *  Boxes are created using five main connection operations : sequential (:),
 *  parallel (,), split (<:), merge (:>), and recursive (~).
 */

#include <stdio.h>
#include <string.h>
#include "boxes.hh"
#include "ppbox.hh"
#include "prim2.hh"
#include "xtended.hh"


/*****************************************************************************
							    	Identifiers
*****************************************************************************/
Sym BOXIDENT = symbol ("BoxIdent");

Tree boxIdent(const char* name)		{ return tree(BOXIDENT, tree(symbol(name)) ); }
bool isBoxIdent(Tree t)				{ return t->node() == Node(BOXIDENT); }
bool isBoxIdent(Tree t0, const char** str)
{
	Tree t1; Sym s;
	if ( isTree(t0, BOXIDENT, t1) && isSym(t1->node(), &s) ) {
		*str = name(s);
		return true;
	} else {
		return false;
	}
}

Пример #14
0
sort * fpa_decl_plugin::mk_rm_sort() {
    return m_manager->mk_sort(symbol("RoundingMode"), sort_info(m_family_id, ROUNDING_MODE_SORT));
}
Пример #15
0
std::string
ShaderInstance::print (const ShaderGroup &group)
{
    std::stringstream out;
    out << "Shader " << shadername() << "\n";
    out << "  symbols:\n";
    for (size_t i = 0;  i < m_instsymbols.size();  ++i) {
        const Symbol &s (*symbol(i));
        s.print (out, 256);
    }
#if 0
    out << "  int consts:\n    ";
    for (size_t i = 0;  i < m_iconsts.size();  ++i)
        out << m_iconsts[i] << ' ';
    out << "\n";
    out << "  float consts:\n    ";
    for (size_t i = 0;  i < m_fconsts.size();  ++i)
        out << m_fconsts[i] << ' ';
    out << "\n";
    out << "  string consts:\n    ";
    for (size_t i = 0;  i < m_sconsts.size();  ++i)
        out << "\"" << Strutil::escape_chars(m_sconsts[i]) << "\" ";
    out << "\n";
#endif
    out << "  code:\n";
    for (size_t i = 0;  i < m_instops.size();  ++i) {
        const Opcode &op (m_instops[i]);
        if (i == (size_t)maincodebegin())
            out << "(main)\n";
        out << "    " << i << ": " << op.opname();
        bool allconst = true;
        for (int a = 0;  a < op.nargs();  ++a) {
            const Symbol *s (argsymbol(op.firstarg()+a));
            out << " " << s->name();
            if (s->symtype() == SymTypeConst) {
                out << " (";
                s->print_vals(out,16);
                out << ")";
            }
            if (op.argread(a))
                allconst &= s->is_constant();
        }
        for (size_t j = 0;  j < Opcode::max_jumps;  ++j)
            if (op.jump(j) >= 0)
                out << " " << op.jump(j);
//        out << "    rw " << Strutil::format("%x",op.argread_bits())
//            << ' ' << op.argwrite_bits();
        if (op.argtakesderivs_all())
            out << " %derivs(" << op.argtakesderivs_all() << ") ";
        if (allconst)
            out << "  CONST";
        std::string filename = op.sourcefile().string();
        size_t slash = filename.find_last_of ("/");
        if (slash != std::string::npos)
            filename.erase (0, slash+1);
        if (filename.length())
            out << "  (" << filename << ":" << op.sourceline() << ")";
        out << "\n";
    }
    if (nconnections()) {
        out << "  connections upstream:\n";
        for (int i = 0, e = nconnections(); i < e; ++i) {
            const Connection &c (connection(i));
            out << "    " << c.dst.type.c_str() << ' '
                << symbol(c.dst.param)->name();
            if (c.dst.arrayindex >= 0)
                out << '[' << c.dst.arrayindex << ']';
            out << " upconnected from layer " << c.srclayer << ' ';
            const ShaderInstance *up = group[c.srclayer];
            out << "(" << up->layername() << ") ";
            out << "    " << c.src.type.c_str() << ' '
                << up->symbol(c.src.param)->name();
            if (c.src.arrayindex >= 0)
                out << '[' << c.src.arrayindex << ']';
            out << "\n";
        }
    }
    return out.str ();
}
Пример #16
0
    void test_finite_product_relation(smt_params fparams, params_ref& params) {
        ast_manager m;
        register_engine re;
        context ctx(m, re, fparams);
        ctx.updt_params(params);
        dl_decl_util dl_util(m);
        relation_manager & rmgr = ctx.get_rel_context()->get_rmanager();

        relation_plugin & rel_plugin = *rmgr.get_relation_plugin(params.get_sym("default_relation", symbol("sparse")));
        ENSURE(&rel_plugin);
        finite_product_relation_plugin plg(rel_plugin, rmgr);

        sort_ref byte_srt_ref(dl_util.mk_sort(symbol("BYTE"), 256), m);
        relation_sort byte_srt = byte_srt_ref;

        relation_signature sig2;
        sig2.push_back(byte_srt);
        sig2.push_back(byte_srt);
        relation_signature sig3(sig2);
        sig3.push_back(byte_srt);
        relation_signature sig4(sig3);
        sig4.push_back(byte_srt);

        app_ref seven_ref(dl_util.mk_numeral(7, byte_srt), m);
        app_ref nine_ref(dl_util.mk_numeral(9, byte_srt), m);

        relation_element seven = seven_ref;
        relation_element nine = nine_ref;

        relation_fact f7(m);
        f7.push_back(seven);
        relation_fact f9(m);
        f9.push_back(nine);

        relation_fact f77(f7);
        f77.push_back(seven);
        relation_fact f79(f7);
        f79.push_back(nine);
        relation_fact f97(f9);
        f97.push_back(seven);
        relation_fact f99(f9);
        f99.push_back(nine);

        relation_fact f779(f77);
        f779.push_back(nine);
        relation_fact f799(f79);
        f799.push_back(nine);
        relation_fact f977(f97);
        f977.push_back(seven);

        relation_fact f7797(f779);
        f7797.push_back(seven);
        relation_fact f7997(f799);
        f7997.push_back(seven);


        bool table_cols2[] = { true, false };
        bool table_cols3[] = { true, false, false };
        bool table_cols4[] = { true, true, false, false };
        scoped_rel<relation_base> r1 = plg.mk_empty(sig2, table_cols2);
        scoped_rel<relation_base> r2 = r1->clone();
        scoped_rel<relation_base> r3 = r2->clone();

        ENSURE(!r1->contains_fact(f77));
        r1->add_fact(f77);
        ENSURE(r1->contains_fact(f77));

        r2->add_fact(f79);
        r3->add_fact(f99);


        r2->display( std::cout << "r2 0\n");
        scoped_rel<relation_base> r4 = r2->clone();
        r2->display( std::cout << "r2 1\n");

        r4->display( std::cout << "r4 0\n");
        ENSURE(!r4->contains_fact(f77));
        ENSURE(r4->contains_fact(f79));
        r4->add_fact(f77);
        r4->display( std::cout << "r4 1\n");
        ENSURE(r4->contains_fact(f77));
        ENSURE(r4->contains_fact(f79));
        r4->add_fact(f99);
        r4->display( std::cout << "r4 2\n");
        ENSURE(r4->contains_fact(f99));


        std::cout << "------ testing union ------\n";
        r2->display( std::cout << "r2\n");
        scoped_ptr<relation_union_fn> union_op = rmgr.mk_union_fn(*r1, *r2, r3.get());
        ENSURE(union_op);
        (*union_op)(*r1, *r2, r3.get());

        r1->display( std::cout << "r1\n");
        r2->display( std::cout << "r2\n");
        r3->display( std::cout << "r3\n");

        ENSURE(r1->contains_fact(f77));
        ENSURE(r1->contains_fact(f79));
        ENSURE(!r1->contains_fact(f99));

        ENSURE(!r3->contains_fact(f77));
        ENSURE(r3->contains_fact(f79));
        ENSURE(r3->contains_fact(f99));

        std::cout << "------ testing join ------\n";

        r1->reset();
        r1->add_fact(f77);
        r1->add_fact(f79);
        r1->add_fact(f97);
        r2->reset();
        r2->add_fact(f97);
        r2->add_fact(f99);

        unsigned col0[] = { 0 };
        unsigned col1[] = { 1 };
        scoped_ptr<relation_join_fn> join_tt = rmgr.mk_join_fn(*r1, *r2, 1, col0, col0);
        scoped_ptr<relation_join_fn> join_tr = rmgr.mk_join_fn(*r1, *r2, 1, col0, col1);
        scoped_ptr<relation_join_fn> join_rr = rmgr.mk_join_fn(*r1, *r2, 1, col1, col1);

        r1->display( std::cout << "r1\n");
        r2->display( std::cout << "r2\n");

        scoped_rel<relation_base> jr_tt = (*join_tt)(*r1, *r2);
        scoped_rel<relation_base> jr_tr = (*join_tr)(*r1, *r2);
        scoped_rel<relation_base> jr_rr = (*join_rr)(*r1, *r2);

        jr_tt->display( std::cout << "tt\n");
        jr_tr->display( std::cout << "tr\n");
        jr_rr->display( std::cout << "rr\n");


        ENSURE(!jr_tt->contains_fact(f7797));
        ENSURE(jr_tr->contains_fact(f7797));
        ENSURE(jr_rr->contains_fact(f7797));


        std::cout << "------ testing project ------\n";

        scoped_rel<relation_base> r31 = plg.mk_empty(sig3, table_cols3);
        r31->add_fact(f779);
        r31->add_fact(f977);
        r31->add_fact(f799);
        
        unsigned rem_1_rel[] = { 1 };
        unsigned rem_2_rel[] = { 1, 2 };
        unsigned rem_1_table[] = { 0 };

        scoped_ptr<relation_transformer_fn> proj_1r = rmgr.mk_project_fn(*r31, 1, rem_1_rel);
        scoped_ptr<relation_transformer_fn> proj_2r = rmgr.mk_project_fn(*r31, 2, rem_2_rel);
        scoped_ptr<relation_transformer_fn> proj_1t = rmgr.mk_project_fn(*r31, 1, rem_1_table);

        scoped_rel<relation_base> sr_1r = (*proj_1r)(*r31);
        scoped_rel<relation_base> sr_2r = (*proj_2r)(*r31);
        scoped_rel<relation_base> sr_1t = (*proj_1t)(*r31);

        ENSURE(sr_1r->contains_fact(f79));
        ENSURE(sr_1r->contains_fact(f97));
        ENSURE(!sr_1r->contains_fact(f77));

        ENSURE(sr_2r->contains_fact(f7));
        ENSURE(sr_2r->contains_fact(f9));

        ENSURE(sr_1t->contains_fact(f79));
        ENSURE(!sr_1t->contains_fact(f97));
        ENSURE(sr_1t->contains_fact(f77));
        ENSURE(sr_1t->contains_fact(f99));

        std::cout << "------ testing filter_interpreted ------\n";

        scoped_rel<relation_base> r41 = plg.mk_empty(sig4, table_cols4);

        r41->add_fact(f7797);
        r41->add_fact(f7997);

        app_ref cond(m.mk_and(
                m.mk_not(m.mk_eq(m.mk_var(1,byte_srt), m.mk_var(2,byte_srt))), //#1!=#2
                m.mk_not(m.mk_eq(m.mk_var(3,byte_srt), m.mk_var(2,byte_srt)))  //#3!=#2
            ), m);
        scoped_ptr<relation_mutator_fn> i_filter = rmgr.mk_filter_interpreted_fn(*r41, cond);
        (*i_filter)(*r41);

        ENSURE(r41->contains_fact(f7797));
        ENSURE(!r41->contains_fact(f7997));

        std::cout << "------ testing filter_by_negation ------\n";

        r31->reset();
        r31->add_fact(f779);
        r31->add_fact(f977);
        r31->add_fact(f799);

        r1->reset();
        r1->add_fact(f77);
        r1->add_fact(f79);

        unsigned nf_r31_cols[] = {1, 0, 1};
        unsigned nf_r1_cols[] = {0, 0, 1};
        scoped_ptr<relation_intersection_filter_fn> neg_filter = rmgr.mk_filter_by_negation_fn(*r31, *r1, 3,
            nf_r31_cols, nf_r1_cols);
        (*neg_filter)(*r31, *r1);

        ENSURE(!r31->contains_fact(f779));
        ENSURE(r31->contains_fact(f977));
        ENSURE(r31->contains_fact(f799));


    }
Пример #17
0
bool
ShaderInstance::mergeable (const ShaderInstance &b, const ShaderGroup &g) const
{
    // Must both be instances of the same master -- very fast early-out
    // for most potential pair comparisons.
    if (master() != b.master())
        return false;

    // If the shaders haven't been optimized yet, they don't yet have
    // their own symbol tables and instructions (they just refer to
    // their unoptimized master), but they may have an "instance
    // override" vector that describes which parameters have
    // instance-specific values or connections.
    bool optimized = (m_instsymbols.size() != 0 || m_instops.size() != 0);

    // Same instance overrides
    if (m_instoverrides.size() || b.m_instoverrides.size()) {
        ASSERT (! optimized);  // should not be post-opt
        ASSERT (m_instoverrides.size() == b.m_instoverrides.size());
        for (size_t i = 0, e = m_instoverrides.size();  i < e;  ++i) {
            if ((m_instoverrides[i].valuesource() == Symbol::DefaultVal ||
                 m_instoverrides[i].valuesource() == Symbol::InstanceVal) &&
                (b.m_instoverrides[i].valuesource() == Symbol::DefaultVal ||
                 b.m_instoverrides[i].valuesource() == Symbol::InstanceVal)) {
                // If both params are defaults or instances, let the
                // instance parameter value checking below handle
                // things. No need to reject default-vs-instance
                // mismatches if the actual values turn out to be the
                // same later.
                continue;
            }

            if (! (equivalent(m_instoverrides[i], b.m_instoverrides[i]))) {
                const Symbol *sym = mastersymbol(i);  // remember, it's pre-opt
                const Symbol *bsym = b.mastersymbol(i);
                if (! sym->everused_in_group() && ! bsym->everused_in_group())
                    continue;
                return false;
            }
            // But still, if they differ in their lockgeom'edness, we can't
            // merge the instances.
            if (m_instoverrides[i].lockgeom() != b.m_instoverrides[i].lockgeom()) {
                return false;
            }
        }
    }

    // Make sure that the two nodes have the same parameter values.  If
    // the group has already been optimized, it's got an
    // instance-specific symbol table to check; but if it hasn't been
    // optimized, we check the symbol table in the master.
    for (int i = firstparam();  i < lastparam();  ++i) {
        const Symbol *sym = optimized ? symbol(i) : mastersymbol(i);
        if (! sym->everused_in_group())
            continue;
        if (sym->typespec().is_closure())
            continue;   // Closures can't have instance override values
        if ((sym->valuesource() == Symbol::InstanceVal || sym->valuesource() == Symbol::DefaultVal)
            && memcmp (param_storage(i), b.param_storage(i),
                       sym->typespec().simpletype().size())) {
            return false;
        }
    }

    if (m_run_lazily != b.m_run_lazily) {
        return false;
    }

    // The connection list need to be the same for the two shaders.
    if (m_connections.size() != b.m_connections.size()) {
        return false;
    }
    if (m_connections != b.m_connections) {
        return false;
    }

    // Make sure system didn't ask for instances that query userdata to be
    // immune from instance merging.
    if (! shadingsys().m_opt_merge_instances_with_userdata
        && (userdata_params() || b.userdata_params())) {
        return false;
    }

    // If there are no "local" ops or symbols, this instance hasn't been
    // optimized yet.  In that case, we've already done enough checking,
    // since the masters being the same and having the same instance
    // params and connections is all it takes.  The rest (below) only
    // comes into play after instances are more fully elaborated from
    // their masters in order to be optimized.
    if (!optimized) {
        return true;
    }

    // Same symbol table
    if (! equivalent (m_instsymbols, b.m_instsymbols)) {
        return false;
    }

    // Same opcodes to run
    if (! equivalent (m_instops, b.m_instops)) {
        return false;
    }
    // Same arguments to the ops
    if (m_instargs != b.m_instargs) {
        return false;
    }

    // Parameter and code ranges
    if (m_firstparam != b.m_firstparam ||
        m_lastparam != b.m_lastparam ||
        m_maincodebegin != b.m_maincodebegin ||
        m_maincodeend != b.m_maincodeend ||
        m_Psym != b.m_Psym || m_Nsym != b.m_Nsym) {
        return false;
    }

    // Nothing left to check, they must be identical!
    return true;
}
Пример #18
0
    void test_functional_columns(smt_params fparams, params_ref& params) {
        ast_manager m;
        register_engine re;
        context ctx(m, re, fparams);
        rel_context_base& rctx = *ctx.get_rel_context();
        ctx.updt_params(params);
        relation_manager & rmgr(rctx.get_rmanager());

        sparse_table_plugin & plugin = 
            static_cast<sparse_table_plugin &>(*rctx.get_rmanager().get_table_plugin(symbol("sparse")));
        ENSURE(&plugin);
        table_signature sig2;
        sig2.push_back(2);
        sig2.push_back(2);
        sig2.set_functional_columns(1);
        ENSURE(plugin.can_handle_signature(sig2));
        
        table_fact f00;
        f00.push_back(0);
        f00.push_back(0);
        table_fact f01;
        f01.push_back(0);
        f01.push_back(1);
        table_fact f11;
        f11.push_back(1);
        f11.push_back(1);

        {
            table_aptr t0 = plugin.mk_empty(sig2);
            ENSURE(t0->empty());
            t0->add_fact(f00);
            ENSURE(!t0->empty());
            ENSURE(t0->get_size_estimate_rows()==1);
            t0->add_fact(f01);
            ENSURE(t0->get_size_estimate_rows()==1);
            t0->add_fact(f11);
            ENSURE(t0->get_size_estimate_rows()==2);

            unsigned rem_cols0[]={0};
            scoped_ptr<table_transformer_fn> project0 = rmgr.mk_project_fn(*t0, 1, rem_cols0);
            table_aptr t1 = (*project0)(*t0);
            ENSURE(t1->get_size_estimate_rows()==2);
            ENSURE(t1->get_signature().functional_columns()==0); //project on non-functional column cancels functional

            unsigned rem_cols1[]={1};
            scoped_ptr<table_transformer_fn> project1 = rmgr.mk_project_fn(*t0, 1, rem_cols1);
            table_aptr t2 = (*project1)(*t0);
            ENSURE(t2->get_size_estimate_rows()==2);

            idx_set acc;
            collector_of_reduced * reducer = alloc(collector_of_reduced, acc);
            scoped_ptr<table_transformer_fn> rproject = rmgr.mk_project_with_reduce_fn(*t0, 1, rem_cols0, reducer);
            table_aptr rt = (*rproject)(*t0);
            ENSURE(acc.num_elems()==1);
            ENSURE(rt->get_size_estimate_rows()==1);
        }
        {
            table_aptr t0 = plugin.mk_empty(sig2);
            t0->add_fact(f01);

            unsigned join_cols[]={1};
            scoped_ptr<table_join_fn> join0 = rmgr.mk_join_fn(*t0, *t0, 1, join_cols, join_cols);
            table_aptr t1 = (*join0)(*t0, *t0);
            ENSURE(t1->get_signature().size()==4);
            ENSURE(t1->get_signature().functional_columns()==2);

            table_fact f0011;
            f0011.push_back(0);
            f0011.push_back(0);
            f0011.push_back(1);
            f0011.push_back(1);
            ENSURE(t1->contains_fact(f0011));
            table_fact f0111 = f0011;
            f0111[1] = 1;
            ENSURE(!t1->contains_fact(f0111));
        }

        {
            table_aptr t0 = plugin.mk_empty(sig2);
            t0->display(std::cout<<"0:");
            ENSURE(t0->get_signature().functional_columns()==1);
            
            table_fact aux_fact;

            aux_fact = f01;
            TRUSTME( t0->suggest_fact(aux_fact) );
            t0->display(std::cout<<"1:");
            ENSURE(t0->contains_fact(f01));
            ENSURE(aux_fact[1]==1);

            aux_fact = f00;
            TRUSTME( !t0->suggest_fact(aux_fact) );
            t0->display(std::cout<<"2:");
            ENSURE(t0->contains_fact(f01));
            ENSURE(!t0->contains_fact(f00));
            ENSURE(aux_fact[1]==1);

            t0->ensure_fact(f00);
            t0->display(std::cout<<"3:");
            ENSURE(t0->contains_fact(f00));
            ENSURE(!t0->contains_fact(f01));
        }
    }
Пример #19
0
tactic * mk_qfidl_tactic(ast_manager & m, params_ref const & p) {
    params_ref main_p;
    main_p.set_bool("elim_and", true);
    main_p.set_bool("blast_distinct", true);
    main_p.set_bool("som", true);

    params_ref lhs_p;
    lhs_p.set_bool("arith_lhs", true);

    params_ref lia2pb_p;
    lia2pb_p.set_uint("lia2pb_max_bits", 4);

    params_ref pb2bv_p;
    pb2bv_p.set_uint("pb2bv_all_clauses_limit", 8);

    params_ref pull_ite_p;
    pull_ite_p.set_bool("pull_cheap_ite", true);
    pull_ite_p.set_bool("local_ctx", true);
    pull_ite_p.set_uint("local_ctx_limit", 10000000);

    tactic * preamble_st = and_then(and_then(mk_simplify_tactic(m),
                                             mk_fix_dl_var_tactic(m),
                                             mk_propagate_values_tactic(m),
                                             mk_elim_uncnstr_tactic(m)
                                             ),
                                    and_then(mk_solve_eqs_tactic(m),
                                             using_params(mk_simplify_tactic(m), lhs_p),
                                             mk_propagate_values_tactic(m),
                                             mk_normalize_bounds_tactic(m),
                                             mk_solve_eqs_tactic(m)));

    
    
    params_ref bv_solver_p;
    // The cardinality constraint encoding generates a lot of shared if-then-else's that can be flattened.
    // Several of them are simplified to and/or. If we flat them, we increase a lot the memory consumption.
    bv_solver_p.set_bool("flat", false); 
    bv_solver_p.set_bool("som", false); 
    // dynamic psm seems to work well.
    bv_solver_p.set_sym("gc", symbol("dyn_psm"));

    tactic * bv_solver = using_params(and_then(mk_simplify_tactic(m),
                                               mk_propagate_values_tactic(m),
                                               mk_solve_eqs_tactic(m),
                                               mk_max_bv_sharing_tactic(m),
                                               mk_bit_blaster_tactic(m),
                                               mk_aig_tactic(),
                                               mk_sat_tactic(m)),
                                      bv_solver_p);

    tactic * try2bv = 
        and_then(using_params(mk_lia2pb_tactic(m), lia2pb_p),
                 mk_propagate_ineqs_tactic(m),
                 using_params(mk_pb2bv_tactic(m), pb2bv_p),
                 fail_if(mk_not(mk_is_qfbv_probe())),
                 bv_solver);
    
    params_ref diff_neq_p;
    diff_neq_p.set_uint("diff_neq_max_k", 25);

    tactic * st = cond(mk_and(mk_lt(mk_num_consts_probe(), mk_const_probe(static_cast<double>(BIG_PROBLEM))),
                              mk_and(mk_not(mk_produce_proofs_probe()),
                                     mk_not(mk_produce_unsat_cores_probe()))),
                       using_params(and_then(preamble_st,
                                             or_else(using_params(mk_diff_neq_tactic(m), diff_neq_p),
                                                     try2bv,
                                                     mk_smt_tactic())),
                                    main_p),
                       mk_smt_tactic());
    
    st->updt_params(p);

    return st;
}
Пример #20
0
void Moc::parse()
{
    QList<NamespaceDef> namespaceList;
    bool templateClass = false;
    while (hasNext()) {
        Token t = next();
        switch (t) {
            case NAMESPACE: {
                int rewind = index;
                if (test(IDENTIFIER)) {
                    if (test(EQ)) {
                        // namespace Foo = Bar::Baz;
                        until(SEMIC);
                    } else if (!test(SEMIC)) {
                        NamespaceDef def;
                        def.name = lexem();
                        next(LBRACE);
                        def.begin = index - 1;
                        until(RBRACE);
                        def.end = index;
                        index = def.begin + 1;
                        namespaceList += def;
                        index = rewind;
                    }
                }
                break;
            }
            case SEMIC:
            case RBRACE:
                templateClass = false;
                break;
            case TEMPLATE:
                templateClass = true;
                break;
            case MOC_INCLUDE_BEGIN:
                currentFilenames.push(symbol().unquotedLexem());
                break;
            case MOC_INCLUDE_END:
                currentFilenames.pop();
                break;
            case Q_DECLARE_INTERFACE_TOKEN:
                parseDeclareInterface();
                break;
            case Q_DECLARE_METATYPE_TOKEN:
                parseDeclareMetatype();
                break;
            case USING:
                if (test(NAMESPACE)) {
                    while (test(SCOPE) || test(IDENTIFIER))
                        ;
                    next(SEMIC);
                }
                break;
            case CLASS:
            case STRUCT: {
                if (currentFilenames.size() <= 1)
                    break;

                ClassDef def;
                if (!parseClassHead(&def))
                    continue;

                while (inClass(&def) && hasNext()) {
                    if (next() == Q_OBJECT_TOKEN) {
                        def.hasQObject = true;
                        break;
                    }
                }

                if (!def.hasQObject)
                    continue;

                for (int i = namespaceList.size() - 1; i >= 0; --i)
                    if (inNamespace(&namespaceList.at(i)))
                        def.qualified.prepend(namespaceList.at(i).name + "::");

                knownQObjectClasses.insert(def.classname);
                knownQObjectClasses.insert(def.qualified);

                continue; }
            default: break;
        }
        if ((t != CLASS && t != STRUCT)|| currentFilenames.size() > 1)
            continue;
        ClassDef def;
        if (parseClassHead(&def)) {
            FunctionDef::Access access = FunctionDef::Private;
            for (int i = namespaceList.size() - 1; i >= 0; --i)
                if (inNamespace(&namespaceList.at(i)))
                    def.qualified.prepend(namespaceList.at(i).name + "::");
            while (inClass(&def) && hasNext()) {
                switch ((t = next())) {
                case PRIVATE:
                    access = FunctionDef::Private;
                    if (test(Q_SIGNALS_TOKEN))
                        error("Signals cannot have access specifier");
                    break;
                case PROTECTED:
                    access = FunctionDef::Protected;
                    if (test(Q_SIGNALS_TOKEN))
                        error("Signals cannot have access specifier");
                    break;
                case PUBLIC:
                    access = FunctionDef::Public;
                    if (test(Q_SIGNALS_TOKEN))
                        error("Signals cannot have access specifier");
                    break;
                case CLASS: {
                    ClassDef nestedDef;
                    if (parseClassHead(&nestedDef)) {
                        while (inClass(&nestedDef) && inClass(&def)) {
                            t = next();
                            if (t >= Q_META_TOKEN_BEGIN && t < Q_META_TOKEN_END)
                                error("Meta object features not supported for nested classes");
                        }
                    }
                } break;
                case Q_SIGNALS_TOKEN:
                    parseSignals(&def);
                    break;
                case Q_SLOTS_TOKEN:
                    switch (lookup(-1)) {
                    case PUBLIC:
                    case PROTECTED:
                    case PRIVATE:
                        parseSlots(&def, access);
                        break;
                    default:
                        error("Missing access specifier for slots");
                    }
                    break;
                case Q_OBJECT_TOKEN:
                    def.hasQObject = true;
                    if (templateClass)
                        error("Template classes not supported by Q_OBJECT");
                    if (def.classname != "Qt" && def.classname != "QObject" && def.superclassList.isEmpty())
                        error("Class contains Q_OBJECT macro but does not inherit from QObject");
                    break;
                case Q_GADGET_TOKEN:
                    def.hasQGadget = true;
                    if (templateClass)
                        error("Template classes not supported by Q_GADGET");
                    break;
                case Q_PROPERTY_TOKEN:
                    parseProperty(&def);
                    break;
                case Q_ENUMS_TOKEN:
                    parseEnumOrFlag(&def, false);
                    break;
                case Q_FLAGS_TOKEN:
                    parseEnumOrFlag(&def, true);
                    break;
                case Q_DECLARE_FLAGS_TOKEN:
                    parseFlag(&def);
                    break;
                case Q_CLASSINFO_TOKEN:
                    parseClassInfo(&def);
                    break;
                case Q_INTERFACES_TOKEN:
                    parseInterfaces(&def);
                    break;
                case Q_PRIVATE_SLOT_TOKEN:
                    parseSlotInPrivate(&def, access);
                    break;
                case ENUM: {
                    EnumDef enumDef;
                    if (parseEnum(&enumDef))
                        def.enumList += enumDef;
                } break;
                default:
                    FunctionDef funcDef;
                    funcDef.access = access;
                    int rewind = index;
                    if (parseMaybeFunction(&funcDef)) {
                        if (access == FunctionDef::Public)
                            def.publicList += funcDef;
                        if (funcDef.isSlot) {
                            def.slotList += funcDef;
                            while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
                                funcDef.wasCloned = true;
                                funcDef.arguments.removeLast();
                                def.slotList += funcDef;
                            }
                        } else if (funcDef.isSignal) {
                            def.signalList += funcDef;
                            while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
                                funcDef.wasCloned = true;
                                funcDef.arguments.removeLast();
                                def.signalList += funcDef;
                            }
                        } else if (funcDef.isInvokable) {
                            def.methodList += funcDef;
                            while (funcDef.arguments.size() > 0 && funcDef.arguments.last().isDefault) {
                                funcDef.wasCloned = true;
                                funcDef.arguments.removeLast();
                                def.methodList += funcDef;
                            }
                        }
                    } else {
                        index = rewind;
                    }
                }
            }

            next(RBRACE);

            if (!def.hasQObject && def.signalList.isEmpty() && def.slotList.isEmpty()
                && def.propertyList.isEmpty() && def.enumDeclarations.isEmpty())
                continue; // no meta object code required


            if (!def.hasQObject && !def.hasQGadget)
                error("Class declarations lacks Q_OBJECT macro.");

            checkSuperClasses(&def);

            classList += def;
            knownQObjectClasses.insert(def.classname);
            knownQObjectClasses.insert(def.qualified);
        }
    }
}
Пример #21
0
/*!
 * \brief draw a symbol at pixel coordinates (alternate)
 *
 * Draws a symbol (one of $GISBASE/etc/symbols/) to the active display.
 * The same as D_symbol(), but it uses a primary and secondary color
 * instead of line and fill color. The primary color is used to draw
 * stroke lines (STRINGs) and as the fill color for polygons. The secondary
 * color is used for polygon outlines.
 *
 *  \param Symb The symbol name (e.g. basic/circle)
 *  \param x0   The starting x display coordinate (pixel)
 *  \param y0   The starting y display coordinate (pixel)
 *  \param primary_color  Primary draw color
 *  \param secondary_color  Secondary draw color
 *  \return void
 */
void D_symbol2(const SYMBOL *Symb, double x0, double y0,
	       const RGBA_Color *primary_color,
	       const RGBA_Color *secondary_color)
{
    symbol(Symb, x0, y0, primary_color, secondary_color, primary_color);
}
 ctx_solver_simplify_tactic(ast_manager & m, params_ref const & p = params_ref()):
     m(m), m_params(p), m_solver(m, m_front_p),  m_arith(m), m_mk_app(m), m_fn(m), m_num_steps(0) {
     sort* i_sort = m_arith.mk_int();
     m_fn = m.mk_func_decl(symbol(0xbeef101), i_sort, m.mk_bool_sort());
 }
Пример #23
0
void
yypower(void)
{
	int n;

	p2 = pop();
	p1 = pop();

	// both base and exponent are rational numbers?

	if (isrational(p1) && isrational(p2)) {
		push(p1);
		push(p2);
		qpow();
		return;
	}

	// both base and exponent are either rational or double?

	if (isnum(p1) && isnum(p2)) {
		push(p1);
		push(p2);
		dpow();
		return;
	}

	if (istensor(p1)) {
		power_tensor();
		return;
	}

	if (p1 == symbol(E) && car(p2) == symbol(LOG)) {
		push(cadr(p2));
		return;
	}

	if ((p1 == symbol(MINFTY) || p1 == symbol(INFTY)) && isnegativeterm(p2)) {
		push_integer(0);
		return;
	}

	if (iszero(p1) && isnegativeterm(p2)) {
		push_symbol(INFTY);
		return;
	}

	if (p1 == symbol(E) && p2 == symbol(MINFTY)) {		
		push_integer(0);
		return;
	}

	if (p1 == symbol(E) && isdouble(p2)) {
		push_double(exp(p2->u.d));
		return;
	}

	//	1 ^ a		->	1

	//	a ^ 0		->	1

	if (equal(p1, one) || iszero(p2)) {
		push(one);
		return;
	}

	//	a ^ 1		->	a

	if (equal(p2, one)) {
		push(p1);
		return;
	}

	//	(a * b) ^ c	->	(a ^ c) * (b ^ c)

	if (car(p1) == symbol(MULTIPLY)) {
		p1 = cdr(p1);
		push(car(p1));
		push(p2);
		power();
		p1 = cdr(p1);
		while (iscons(p1)) {
			push(car(p1));
			push(p2);
			power();
			multiply();
			p1 = cdr(p1);
		}
		return;
	}

	//	(a ^ b) ^ c	->	a ^ (b * c)

	if (car(p1) == symbol(POWER)) {
		push(cadr(p1));
		push(caddr(p1));
		push(p2);
		multiply();
		power();
		return;
	}

	//	(a + b) ^ n	->	(a + b) * (a + b) ...

	if (expanding && isadd(p1) && isnum(p2)) {
		push(p2);
		n = pop_integer();
		if (n > 1) {
			power_sum(n);
			return;
		}
	}

	//	sin(x) ^ 2n -> (1 - cos(x) ^ 2) ^ n

	if (trigmode == 1 && car(p1) == symbol(SIN) && iseveninteger(p2)) {
		push_integer(1);
		push(cadr(p1));
		cosine();
		push_integer(2);
		power();
		subtract();
		push(p2);
		push_rational(1, 2);
		multiply();
		power();
		return;
	}

	//	cos(x) ^ 2n -> (1 - sin(x) ^ 2) ^ n

	if (trigmode == 2 && car(p1) == symbol(COS) && iseveninteger(p2)) {
		push_integer(1);
		push(cadr(p1));
		sine();
		push_integer(2);
		power();
		subtract();
		push(p2);
		push_rational(1, 2);
		multiply();
		power();
		return;
	}

	// complex number? (just number, not expression)

	if (iscomplexnumber(p1)) {

		// integer power?

		// n will be negative here, positive n already handled

		if (isinteger(p2)) {

			//               /        \  n
			//         -n   |  a - ib  |
			// (a + ib)   = | -------- |
			//              |   2   2  |
			//               \ a + b  /

			push(p1);
			conjugate();
			p3 = pop();
			push(p3);
			push(p3);
			push(p1);
			multiply();
			divide();
			push(p2);
			negate();
			power();
			return;
		}

		// noninteger or floating power?

		if (isnum(p2)) {

#if 1			// use polar form
			push(p1);
			mag();
			push(p2);
			power();
			push_integer(-1);
			push(p1);
			arg();
			push(p2);
			multiply();
			push(symbol(PI));
			divide();
			power();
			multiply();

#else			// use exponential form
			push(p1);
			mag();
			push(p2);
			power();
			push(symbol(E));
			push(p1);
			arg();
			push(p2);
			multiply();
			push(imaginaryunit);
			multiply();
			power();
			multiply();
#endif
			return;
		}
	}

	if (simplify_polar())
		return;

	push_symbol(POWER);
	push(p1);
	push(p2);
	list(3);
}
Пример #24
0
void
absval(void)
{
	int h;
	save();
	p1 = pop();

	if (istensor(p1)) {
		absval_tensor();
		restore();
		return;
	}

	if (isnum(p1)) {
		push(p1);
		if (isnegativenumber(p1))
			negate();
		restore();
		return;
	}

	if (iscomplexnumber(p1)) {
		push(p1);
		push(p1);
		conjugate();
		multiply();
		push_rational(1, 2);
		power();
		restore();
		return;
	}

	// abs(1/a) evaluates to 1/abs(a)

	if (car(p1) == symbol(POWER) && isnegativeterm(caddr(p1))) {
		push(p1);
		reciprocate();
		absval();
		reciprocate();
		restore();
		return;
	}

	// abs(a*b) evaluates to abs(a)*abs(b)

	if (car(p1) == symbol(MULTIPLY)) {
		h = tos;
		p1 = cdr(p1);
		while (iscons(p1)) {
			push(car(p1));
			absval();
			p1 = cdr(p1);
		}
		multiply_all(tos - h);
		restore();
		return;
	}

	if (isnegativeterm(p1) || (car(p1) == symbol(ADD) && isnegativeterm(cadr(p1)))) {
		push(p1);
		negate();
		p1 = pop();
	}

	push_symbol(ABS);
	push(p1);
	list(2);

	restore();
}
Пример #25
0
// Return symbol of atomic number 'i'
const char* ElementMap::symbol(Atom* i)
{
	return symbol(i->element());
}
Пример #26
0
void Preprocessor::preprocess(const QByteArray &filename, Symbols &preprocessed)
{
    currentFilenames.push(filename);
    preprocessed.reserve(preprocessed.size() + symbols.size());
    while (hasNext()) {
        Token token = next();

        switch (token) {
        case PP_INCLUDE:
        {
            int lineNum = symbol().lineNum;
            QByteArray include;
            bool local = false;
            if (test(PP_STRING_LITERAL)) {
                local = lexem().startsWith('\"');
                include = unquotedLexem();
            } else
                continue;
            until(PP_NEWLINE);

            // #### stringery
            QFileInfo fi;
            if (local)
                fi.setFile(QFileInfo(QString::fromLocal8Bit(filename.constData())).dir(), QString::fromLocal8Bit(include.constData()));
            for (int j = 0; j < Preprocessor::includes.size() && !fi.exists(); ++j) {
                const IncludePath &p = Preprocessor::includes.at(j);
                fi.setFile(QString::fromLocal8Bit(p.path.constData()), QString::fromLocal8Bit(include.constData()));
                // try again, maybe there's a file later in the include paths with the same name
                // (186067)
                if (fi.isDir()) {
                    fi = QFileInfo();
                    continue;
                }
            }

            if (!fi.exists() || fi.isDir())
                continue;
            include = fi.canonicalFilePath().toLocal8Bit();

            if (Preprocessor::preprocessedIncludes.contains(include))
                continue;
            Preprocessor::preprocessedIncludes.insert(include);

            QFile file(QString::fromLocal8Bit(include.constData()));
            if (!file.open(QFile::ReadOnly))
                continue;

            QByteArray input = file.readAll();
            file.close();
            if (input.isEmpty())
                continue;

            Symbols saveSymbols = symbols;
            int saveIndex = index;

            // phase 1: get rid of backslash-newlines
            input = cleaned(input);

            // phase 2: tokenize for the preprocessor
            symbols = tokenize(input);
            input.clear();

            index = 0;

            // phase 3: preprocess conditions and substitute macros
            preprocessed += Symbol(0, MOC_INCLUDE_BEGIN, include);
            preprocess(include, preprocessed);
            preprocessed += Symbol(lineNum, MOC_INCLUDE_END, include);

            symbols = saveSymbols;
            index = saveIndex;
            continue;
        }
        case PP_DEFINE:
        {
            next(IDENTIFIER);
            QByteArray name = lexem();
            int start = index;
            until(PP_NEWLINE);
            Macro macro;
            macro.symbols.reserve(index - start - 1);
            for (int i = start; i < index - 1; ++i)
                macro.symbols += symbols.at(i);
            macros.insert(name, macro);
            continue;
        }
        case PP_UNDEF: {
            next(IDENTIFIER);
            QByteArray name = lexem();
            until(PP_NEWLINE);
            macros.remove(name);
            continue;
        }
        case PP_IDENTIFIER:
        {
//             if (macros.contains(symbol()))
//                 ;
        }
            // we _could_ easily substitute macros by the following
            // four lines, but we choose not to.
            /*
            if (macros.contains(sym.lexem())) {
                preprocessed += substitute(macros, symbols, i);
                continue;
            }
            */
            break;
        case PP_HASH:
            until(PP_NEWLINE);
            continue; // skip unknown preprocessor statement
        case PP_IFDEF:
        case PP_IFNDEF:
        case PP_IF:
            while (!evaluateCondition()) {
                if (!skipBranch())
                    break;
                if (test(PP_ELIF)) {
                } else {
                    until(PP_NEWLINE);
                    break;
                }
            }
            continue;
        case PP_ELIF:
        case PP_ELSE:
            skipUntilEndif();
            // fall through
        case PP_ENDIF:
            until(PP_NEWLINE);
            continue;
        case SIGNALS:
        case SLOTS: {
            Symbol sym = symbol();
            if (macros.contains("QT_NO_KEYWORDS"))
                sym.token = IDENTIFIER;
            else
                sym.token = (token == SIGNALS ? Q_SIGNALS_TOKEN : Q_SLOTS_TOKEN);
            preprocessed += sym;
        } continue;
        default:
            break;
        }
        preprocessed += symbol();
    }

    currentFilenames.pop();
}
//!  Update the widget that represents the curve on the legend
void QwtPlotCurve::updateLegend(QwtLegend *legend) const
{
    if ( !legend )
        return;

    QwtPlotItem::updateLegend(legend);

    QWidget *widget = legend->find(this);
    if ( !widget || !widget->inherits("QwtLegendItem") )
        return;

    QwtLegendItem *legendItem = (QwtLegendItem *)widget;

#if QT_VERSION < 0x040000
    const bool doUpdate = legendItem->isUpdatesEnabled();
#else
    const bool doUpdate = legendItem->updatesEnabled();
#endif
    legendItem->setUpdatesEnabled(false);

    const int policy = legend->displayPolicy();

    if (policy == QwtLegend::FixedIdentifier)
    {
        int mode = legend->identifierMode();

        if (mode & QwtLegendItem::ShowLine)
            legendItem->setCurvePen(pen());

        if (mode & QwtLegendItem::ShowSymbol)
            legendItem->setSymbol(symbol());

        if (mode & QwtLegendItem::ShowText)
            legendItem->setText(title());
        else
            legendItem->setText(QwtText());

        legendItem->setIdentifierMode(mode);
    }
    else if (policy == QwtLegend::AutoIdentifier)
    {
        int mode = 0;

        if (QwtPlotCurve::NoCurve != style())
        {
            legendItem->setCurvePen(pen());
            mode |= QwtLegendItem::ShowLine;
        }
        if (QwtSymbol::NoSymbol != symbol().style())
        {
            legendItem->setSymbol(symbol());
            mode |= QwtLegendItem::ShowSymbol;
        }
        if ( !title().isEmpty() )
        {
            legendItem->setText(title());
            mode |= QwtLegendItem::ShowText;
        }
        else
        {
            legendItem->setText(QwtText());
        }
        legendItem->setIdentifierMode(mode);
    }

    legendItem->setUpdatesEnabled(doUpdate);
    legendItem->update();
}
Пример #28
0
void CIteratorThread::InitIteratorLoop()
{
	int			e = SUCCESS;
	CGrammar	gram;

	write_log(prefs.debug_prwin(), "[PrWinThread] Initializing iterator loop\n");
	// Set starting status and parameters
	iter_vars.set_iterator_thread_running(true);
	iter_vars.set_iterator_thread_complete(false);
	iter_vars.set_iterator_thread_progress(0);
	iter_vars.set_nit(10000); //!! f$prwin_number_of_iterations")
	iter_vars.set_f$p(p_symbol_engine_prwin->nopponents_for_prwin());
	iter_vars.set_br(p_betround_calculator->betround());

	for (int i=0; i<k_number_of_cards_per_player; i++)
		iter_vars.set_pcard(i, p_scraper->card_player((int) p_symbol_engine_userchair->userchair(), i));

	for (int i=0; i<k_number_of_community_cards; i++)
		iter_vars.set_ccard(i, p_scraper->card_common(i));

	iter_vars.set_prwin(0);
	iter_vars.set_prtie(0);
	iter_vars.set_prlos(0);

	// player cards
	CardMask_RESET(_plCards);
	CardMask_RESET(_comCards);
	_nplCards = _ncomCards = 0;

	// Counters
	_win = _tie = _los = 0;

	// setup masks
	for (int i=0; i<k_number_of_cards_per_player; i++)
	{
		if (iter_vars.pcard(i) != CARD_BACK && iter_vars.pcard(i) != CARD_NOCARD)
		{
			CardMask_SET(_plCards, iter_vars.pcard(i));
			_nplCards++;
		}
	}
	for (int i=0; i<k_number_of_community_cards; i++)
	{
		if (iter_vars.ccard(i) != CARD_BACK && iter_vars.ccard(i) != CARD_NOCARD)
		{
			CardMask_SET(_comCards, iter_vars.ccard(i));
			_ncomCards++;
		}
	}

	//Weighted prwin only for nopponents <=13
	e = SUCCESS;
	_willplay = (int) gram.CalcF$symbol(p_formula, "f$willplay", &e);
	e = SUCCESS;
	_wontplay = (int) gram.CalcF$symbol(p_formula, "f$wontplay", &e);
	e = SUCCESS;
	_mustplay = (int) gram.CalcF$symbol(p_formula, "f$mustplay", &e);
	e = SUCCESS;
	_topclip = (int) gram.CalcF$symbol(p_formula, "f$topclip", &e);

	// Call prw1326 callback if needed
	if (_prw1326.useme==1326 && 
		_prw1326.usecallback==1326 && 
		(p_betround_calculator->betround()!=1 || _prw1326.preflop==1326) )
	{
		_prw1326.prw_callback(); //Matrix 2008-05-09
	}
}
Пример #29
0
static void tst1() {
    symbol s1("foo");
    symbol s2("boo");
    symbol s3("foo");
    ENSURE(s1 != s2);
    ENSURE(s1 == s3);
    std::cout << s1 << " " << s2 << " " << s3 << "\n";
    ENSURE(s1 == "foo");
    ENSURE(s1 != "boo");
    ENSURE(s2 != "foo");
    ENSURE(s3 == "foo");
    ENSURE(s2 == "boo");

    ENSURE(lt(s2, s1));
    ENSURE(!lt(s1, s2));
    ENSURE(!lt(s1, s3));
    ENSURE(lt(symbol("abcc"), symbol("abcd")));
    ENSURE(!lt(symbol("abcd"), symbol("abcc")));
    ENSURE(lt(symbol("abc"), symbol("abcc")));
    ENSURE(!lt(symbol("abcd"), symbol("abc")));
    ENSURE(lt(symbol(10), s1));
    ENSURE(!lt(s1, symbol(10)));
    ENSURE(lt(symbol(10), symbol(20)));
    ENSURE(!lt(symbol(20), symbol(10)));
    ENSURE(!lt(symbol(10), symbol(10)));
    ENSURE(lt(symbol("a"), symbol("b")));
    ENSURE(!lt(symbol("z"), symbol("b")));
    ENSURE(!lt(symbol("zzz"), symbol("b")));
    ENSURE(lt(symbol("zzz"), symbol("zzzb")));
}
Пример #30
0
void symbol_enforce_type_assert(arg_list_t **a, int type)
{
	*a = symbol();
	arg_enforce_type_assert(a, type);
}