Пример #1
0
 int check_operation(ast::abstract::Operation* op) {
     assert(op != nullptr);
     switch(*op) {
     case ast::VariableNode:
         return check_variable(dynamic_cast<ast::Variable*>(op));
         break;
     case ast::ConstantNode:
         return check_constant(dynamic_cast<ast::Constant*>(op));
         break;
     case ast::CastNode:
         return check_cast(dynamic_cast<ast::Cast*>(op));
         break;
     case ast::UnOpNode:
         return check_un_op(dynamic_cast<ast::UnOp*>(op));
         break;
     case ast::BinOpNode:
         return check_bin_op(dynamic_cast<ast::BinOp*>(op));
         break;
     case ast::CallNode:
         return check_call(dynamic_cast<ast::Call*>(op));
         break;
     }
     assert(false);
     return EXIT_FAILURE;
 }
Пример #2
0
	booster::shared_ptr<json_call> json_rpc_server::release_call()
	{
		check_call();
		current_call_->attach_context(release_context());
		booster::shared_ptr<json_call> call = current_call_;
		current_call_.reset();
		return call;
	}
Пример #3
0
Файл: bind.hpp Проект: 41i/hpx
            BOOST_FORCEINLINE
            typename result<one_shot_wrapper()>::type
            operator()()
            {
                typedef typename result<one_shot_wrapper()>::type result_type;

                check_call();
                return util::invoke_r<result_type>(_f);
            }
Пример #4
0
void check_fun(Fun c) {
	BOOST_CHECK((same_type<typename function_traits<Fun>::return_type, int>::value));
	BOOST_CHECK_EQUAL(function_traits<Fun>::argc, 2);
	BOOST_CHECK((same_type<typename function_traits<Fun>::template argument_type<0>, bool>::value));
	BOOST_CHECK((same_type<typename function_traits<Fun>::template argument_type<1>, long>::value));
	BOOST_CHECK((same_type<typename function_traits<Fun>::function_type, int(bool, long)>::value));

	BOOST_CHECK((same_type<typename callable_traits<Fun>::callable_category, function_ptr_tag>::value));
	check_call(std::forward<Fun>(c));
}
Пример #5
0
/*
 * Function name: load_room
 * Description  : Finds a room object for a given array index.
 * Arguments    : int index - of the file name entry in the room_exits array.
 * Returns      : object - pointer to the room corresponding to the argument
 *                         or 0 if not found.
 */
object
load_room(int index)
{
    mixed droom;
    string err;
    object ob;

    droom = check_call(room_exits[index]);
    if (objectp(droom))
    {
	return droom;
    }

    /* Handle linkrooms that get destructed, bad wizard... baa-aad wizard. */
    if (!stringp(droom))
    {
	remove_exit(room_exits[index + 1]);
	this_player()->move_living("X", query_link_master());
	return 0;
    }

    ob = find_object(droom);
    if (objectp(ob))
    {
	return ob;
    }

    if (err = LOAD_ERR(droom))
    {
	SECURITY->log_loaderr(droom, environment(this_object()),
			      room_exits[index + 1], this_object(), err);
	write("Err in load:" + err + " <" + droom +
	    ">\nPlease make a bugreport about this.\n");
	return 0;
    }
    return find_object(droom);
}
Пример #6
0
static tree
scan_function (tree *tp, 
		      int *walk_subtrees, 
		      void *data)
{
  struct cgraph_node *fn = data;
  tree t = *tp;
  funct_state local = get_function_state (fn);

  switch (TREE_CODE (t))  
    {
    case VAR_DECL:
      if (DECL_INITIAL (t))
	walk_tree (&DECL_INITIAL (t), scan_function, fn, visited_nodes);
      *walk_subtrees = 0;
      break;

    case MODIFY_EXPR:
      {
	/* First look on the lhs and see what variable is stored to */
	tree lhs = TREE_OPERAND (t, 0);
	tree rhs = TREE_OPERAND (t, 1);
	check_lhs_var (local, lhs);

	/* For the purposes of figuring out what the cast affects */

	/* Next check the operands on the rhs to see if they are ok. */
	switch (TREE_CODE_CLASS (TREE_CODE (rhs))) 
	  {
	  case tcc_binary:	    
 	    {
 	      tree op0 = TREE_OPERAND (rhs, 0);
 	      tree op1 = TREE_OPERAND (rhs, 1);
 	      check_rhs_var (local, op0);
 	      check_rhs_var (local, op1);
	    }
	    break;
	  case tcc_unary:
 	    {
 	      tree op0 = TREE_OPERAND (rhs, 0);
 	      check_rhs_var (local, op0);
 	    }

	    break;
	  case tcc_reference:
	    check_rhs_var (local, rhs);
	    break;
	  case tcc_declaration:
	    check_rhs_var (local, rhs);
	    break;
	  case tcc_expression:
	    switch (TREE_CODE (rhs)) 
	      {
	      case ADDR_EXPR:
		check_rhs_var (local, rhs);
		break;
	      case CALL_EXPR: 
		check_call (local, rhs);
		break;
	      default:
		break;
	      }
	    break;
	  default:
	    break;
	  }
	*walk_subtrees = 0;
      }
      break;

    case ADDR_EXPR:
      /* This case is here to find addresses on rhs of constructors in
	 decl_initial of static variables. */
      check_rhs_var (local, t);
      *walk_subtrees = 0;
      break;

    case LABEL_EXPR:
      if (DECL_NONLOCAL (TREE_OPERAND (t, 0)))
	/* Target of long jump. */
	local->pure_const_state = IPA_NEITHER;
      break;

    case CALL_EXPR: 
      check_call (local, t);
      *walk_subtrees = 0;
      break;
      
    case ASM_EXPR:
      get_asm_expr_operands (local, t);
      *walk_subtrees = 0;
      break;
      
    default:
      break;
    }
  return NULL;
}
Пример #7
0
	std::string json_rpc_server::method()
	{
		check_call();
		return current_call_->method();
	}
Пример #8
0
	void json_rpc_server::return_error(json::value const &e)
	{
		check_call();
		current_call_->return_error(context(),e);
	}
Пример #9
0
	void json_rpc_server::return_result(json::value const &r)
	{
		check_call();
		current_call_->return_result(context(),r);
	}
Пример #10
0
	bool json_rpc_server::notification()
	{
		check_call();
		return current_call_->notification();
	}
Пример #11
0
 void visitCall(Call * p)
 {
     p->m_attribute.m_scope = m_st->get_scope();
     check_call(p);
     p->visit_children(this);
 }
Пример #12
0
// Update the datestamp for a buffered directory
// Called from LISTER PROCESS
void update_buffer_stamp(Lister *lister)
{
	BPTR lock;
	struct FileInfoBlock __aligned info;
	char path[512];
/*
	DirBuffer *buffer=0;
*/

#ifdef DEBUG
	if (lister) check_call("update_buffer_stamp",lister);
#endif

	// Invalid window?
	if (!lister) return;

	// Get current path and disk stamp
	strcpy(path,lister->cur_buffer->buf_Path);

	// Lock the path
	if (lock=Lock(path,ACCESS_READ))
	{
		// Examine and unlock
		Examine(lock,&info);
		UnLock(lock);

		// Store new stamp
		lister->cur_buffer->buf_DirectoryDate=info.fib_Date;
	}

/*
	// Couldn't lock, use zero datestamp
	else
	{
		info.fib_Date.ds_Days=0;
		info.fib_Date.ds_Minute=0;
		info.fib_Date.ds_Tick=0;
	}

	// Lock buffer list
	lock_listlock(&GUI->buffer_list,TRUE);

	// Find all instances of this path
	while (buffer=
		(lister_find_buffer(
			lister,
			buffer,
			path,
			&lister->cur_buffer->buf_VolumeDate,
			0,
			LISTER_BFPF_DONT_MOVE|LISTER_BFPF_DONT_LOCK|LISTER_BFPF_DONT_TEST)))
	{
		// Not the original buffer?
		if (buffer!=lister->cur_buffer)
		{
			// If buffer is locked, tell its lister to get this copy
			if (buffer->buf_CurrentLister)
			{
				IPC_Command(
					buffer->buf_CurrentLister->ipc,
					LISTER_COPY_BUFFER,
					0,
					lister->cur_buffer,
					0,
					0);
			}

			// Otherwise, copy into the buffer
			else
			{
				buffer_copy(lister->cur_buffer,buffer,0);
			}
		}

		// Get next
		buffer=(DirBuffer *)buffer->node.ln_Succ;
	}

	// While there's parents to look for
	while (path_parent(path))
	{
		// Initialise
		buffer=0;
		lock=0;

		// Look for all parents
		while (buffer=
			(lister_find_buffer(
				lister,
				buffer,
				path,
				&lister->cur_buffer->buf_VolumeDate,
				0,
				LISTER_BFPF_DONT_MOVE|LISTER_BFPF_DONT_LOCK|LISTER_BFPF_DONT_TEST)))
		{
			// Need to get date?
			if (!lock)
			{
				// Lock the path
				if (!(lock=Lock(path,ACCESS_READ)))
					break;

				// Examine and unlock
				Examine(lock,&info);
				UnLock(lock);
			}

			// Store datestamp
			buffer->buf_DirectoryDate=info.fib_Date;

			// Get next
			buffer=(DirBuffer *)buffer->node.ln_Succ;
		}
	}

	// Unlock buffer list
	unlock_listlock(&GUI->buffer_list);
*/
}
Пример #13
0
// Checks buffers to see if they need re-reading
// Called from the LISTER PROCESS
void lister_check_old_buffer(
	Lister *lister,
	BOOL force)
{
	int reread=0;

#ifdef DEBUG
	if (lister) check_call("lister_check_old_buffer",lister);
#endif

	// If re-read flag is set, and buffer is valid
	if ((force || environment->env->settings.dir_flags&DIRFLAGS_REREAD_CHANGED) &&
		lister->cur_buffer->flags&DWF_VALID &&
		lister->cur_buffer->buf_Path[0] &&
		!lister->cur_buffer->buf_CustomHandler[0])
	{
		DirBuffer *buffer;
		BPTR lock;

		// Get current buffer
		buffer=lister->cur_buffer;

		// Return on a device list
		if (!(IsListEmpty((struct List *)&buffer->entry_list)) &&
			((DirEntry *)buffer->entry_list.mlh_Head)->de_Node.dn_Type==ENTRY_DEVICE) return;

		// Lock and examine directory
		if (lock=Lock(buffer->buf_Path,ACCESS_READ))
		{
			// Examine and unlock
			Examine(lock,lister->fib);
			UnLock(lock);

			// Make sure it's a directory
			if (lister->fib->fib_DirEntryType>0)
			{
				// See if datestamp has changed
				if (CompareDates(&buffer->buf_DirectoryDate,&lister->fib->fib_Date)>0)
					reread=1;

				// Or, see if disk has changed
				else
				if (buffer->buf_VolumeLabel[0])
				{
					char rootname[512];

					// Get root of current directory
					if (get_path_root(buffer->buf_Path,rootname,0))
					{
						// See if disk name is not the same
						if (strcmp(rootname,buffer->buf_VolumeLabel)!=0)
							reread=1;
					}
				}
			}
		}

		// Did we need to re-read?
		if (reread)
		{
			// Re-read directory
			read_directory(
				lister,
				buffer->buf_Path,
				GETDIRF_RESELECT);
		}
	}
}
Пример #14
0
// Searches for an empty buffer, or one with the same name (preferred)
// If a suitable buffer is not found, it uses the current buffer
// Called from the LISTER PROCESS
DirBuffer *lister_buffer_find_empty(Lister *lister,char *path,struct DateStamp *stamp)
{
	DirBuffer *buffer,*first_empty=0,*first_unlocked=0;

#ifdef DEBUG
	if (lister) check_call("lister_buffer_find_empty",lister);
#endif

	// Check we're not showing special
	check_special_buffer(lister,1);

	// If current buffer is empty, use that one
	if (!(lister->cur_buffer->flags&DWF_VALID))
	{
		// Lock buffer
		buffer_lock(lister->cur_buffer,TRUE);

		// Free buffer
		buffer_freedir(lister->cur_buffer,1);

		// Unlock it
		buffer_unlock(lister->cur_buffer);
		return lister->cur_buffer;
	}

	// Lock buffer list
	lock_listlock(&GUI->buffer_list,TRUE);

	// Go through buffers in this list (backwards)
	for (buffer=(DirBuffer *)GUI->buffer_list.list.lh_TailPred;
		buffer->node.ln_Pred;
		buffer=(DirBuffer *)buffer->node.ln_Pred)
	{
		// See if this directory is available and matches our path
		if (path && stricmp(buffer->buf_Path,path)==0 &&
			(!stamp || CompareDates(&buffer->buf_VolumeDate,stamp)==0))
		{
			// Not locked, or in use by this lister?
			if (!buffer->buf_CurrentLister || buffer->buf_CurrentLister==lister)
			{
				// Store pointer
				first_empty=buffer;
				break;
			}
		}

		// If directory is empty, store pointer (if the first one)
		if (!buffer->buf_CurrentLister && !(buffer->flags&DWF_VALID) && !first_empty)
			first_empty=buffer;

		// First unlocked buffer?
		if (!buffer->buf_CurrentLister && !first_unlocked)
		{
			// Because buffers are moved to the head of the list whenever
			// they are accessed, this will point to the unlocked buffer
			// that was accessed the longest time ago
			first_unlocked=buffer;
		}
	}

	// If we found an empty one, use that one
	if (!(buffer=first_empty))
	{
		// Allocate a new buffer if we're allowed to
		if (GUI->buffer_count<environment->env->settings.max_buffer_count &&
			!(environment->env->settings.dir_flags&DIRFLAGS_DISABLE_CACHING))
		{
			// If this fails, use first unlocked
			buffer=lister_new_buffer(lister);
		}
	}

	// If nothing yet, use first unlocked buffer (if there is one)
	if (!buffer && !(buffer=first_unlocked))
	{
		// If not, re-use current buffer
		buffer=lister->cur_buffer;
	}

	// Lock buffer
	buffer_lock(buffer,TRUE);

	// Free buffer
	buffer_freedir(buffer,1);

	// Unlock buffer
	buffer_unlock(buffer);

	// Show buffer in lister
	lister_show_buffer(lister,buffer,0,1);

	// Unlock buffer list
	unlock_listlock(&GUI->buffer_list);

	// Return current buffer
	return lister->cur_buffer;
}
Пример #15
0
 inline typename util::result_of<F&&(Ts&&...)>::type
 operator()(Ts&&... vs)
 {
     check_call();
     return util::invoke(std::move(_f), std::forward<Ts>(vs)...);
 }
Пример #16
0
/* Look into pointer pointed to by GSIP and figure out what interesting side
   effects it has.  */
static void
check_stmt (gimple_stmt_iterator *gsip, funct_state local, bool ipa)
{
  gimple stmt = gsi_stmt (*gsip);

  if (is_gimple_debug (stmt))
    return;

  if (dump_file)
    {
      fprintf (dump_file, "  scanning: ");
      print_gimple_stmt (dump_file, stmt, 0, 0);
    }

  if (gimple_has_volatile_ops (stmt)
      && !gimple_clobber_p (stmt))
    {
      local->pure_const_state = IPA_NEITHER;
      if (dump_file)
	fprintf (dump_file, "    Volatile stmt is not const/pure\n");
    }

  /* Look for loads and stores.  */
  walk_stmt_load_store_ops (stmt, local,
			    ipa ? check_ipa_load : check_load,
			    ipa ? check_ipa_store :  check_store);

  if (gimple_code (stmt) != GIMPLE_CALL
      && stmt_could_throw_p (stmt))
    {
      if (cfun->can_throw_non_call_exceptions)
	{
	  if (dump_file)
	    fprintf (dump_file, "    can throw; looping\n");
	  local->looping = true;
	}
      if (stmt_can_throw_external (stmt))
	{
	  if (dump_file)
	    fprintf (dump_file, "    can throw externally\n");
	  local->can_throw = true;
	}
      else
	if (dump_file)
	  fprintf (dump_file, "    can throw\n");
    }
  switch (gimple_code (stmt))
    {
    case GIMPLE_CALL:
      check_call (local, stmt, ipa);
      break;
    case GIMPLE_LABEL:
      if (DECL_NONLOCAL (gimple_label_label (stmt)))
	/* Target of long jump. */
	{
          if (dump_file)
            fprintf (dump_file, "    nonlocal label is not const/pure\n");
	  local->pure_const_state = IPA_NEITHER;
	}
      break;
    case GIMPLE_ASM:
      if (gimple_asm_clobbers_memory_p (stmt))
	{
	  if (dump_file)
	    fprintf (dump_file, "    memory asm clobber is not const/pure\n");
	  /* Abandon all hope, ye who enter here. */
	  local->pure_const_state = IPA_NEITHER;
	}
      if (gimple_asm_volatile_p (stmt))
	{
	  if (dump_file)
	    fprintf (dump_file, "    volatile is not const/pure\n");
	  /* Abandon all hope, ye who enter here. */
	  local->pure_const_state = IPA_NEITHER;
          local->looping = true;
	}
      return;
    default:
      break;
    }
}
Пример #17
0
	json::array const &json_rpc_server::params()
	{
		check_call();
		return current_call_->params();
	}
Пример #18
0
static tree
scan_for_static_refs (tree *tp, 
		      int *walk_subtrees, 
		      void *data)
{
  struct cgraph_node *fn = (struct cgraph_node *) data;
  tree t = *tp;
  ipa_reference_local_vars_info_t local = NULL;
  if (fn)
    local = get_reference_vars_info_from_cgraph (fn)->local;

  switch (TREE_CODE (t))  
    {
    case VAR_DECL:
      if (DECL_INITIAL (t))
	walk_tree (&DECL_INITIAL (t), scan_for_static_refs, fn, visited_nodes);
      *walk_subtrees = 0;
      break;

    case GIMPLE_MODIFY_STMT:
      {
	/* First look on the lhs and see what variable is stored to */
	tree lhs = GIMPLE_STMT_OPERAND (t, 0);
	tree rhs = GIMPLE_STMT_OPERAND (t, 1);
	check_lhs_var (local, lhs);

	/* For the purposes of figuring out what the cast affects */

	/* Next check the operands on the rhs to see if they are ok. */
	switch (TREE_CODE_CLASS (TREE_CODE (rhs))) 
	  {
	  case tcc_binary:	    
	  case tcc_comparison:	    
 	    {
 	      tree op0 = TREE_OPERAND (rhs, 0);
 	      tree op1 = TREE_OPERAND (rhs, 1);
 	      check_rhs_var (local, op0);
 	      check_rhs_var (local, op1);
	    }
	    break;
	  case tcc_unary:
 	    {
 	      tree op0 = TREE_OPERAND (rhs, 0);
 	      check_rhs_var (local, op0);
 	    }

	    break;
	  case tcc_reference:
	    check_rhs_var (local, rhs);
	    break;
	  case tcc_declaration:
	    check_rhs_var (local, rhs);
	    break;
	  case tcc_expression:
	    switch (TREE_CODE (rhs)) 
	      {
	      case ADDR_EXPR:
		check_rhs_var (local, rhs);
		break;
	      default:
		break;
	      }
	    break;
	  case tcc_vl_exp:
	    switch (TREE_CODE (rhs))
	      {
	      case CALL_EXPR:
		check_call (local, rhs);
		break;
	      default:
		break;
	      }
	    break;
	  default:
	    break;
	  }
	*walk_subtrees = 0;
      }
      break;

    case ADDR_EXPR:
      /* This case is here to find addresses on rhs of constructors in
	 decl_initial of static variables. */
      check_rhs_var (local, t);
      *walk_subtrees = 0;
      break;

    case LABEL_EXPR:
      if (DECL_NONLOCAL (TREE_OPERAND (t, 0)))
	{
	  /* Target of long jump. */
	  local->calls_read_all = true;
	  local->calls_write_all = true;
	}
      break;

    case CALL_EXPR: 
      check_call (local, t);
      *walk_subtrees = 0;
      break;
      
    case ASM_EXPR:
      get_asm_expr_operands (local, t);
      *walk_subtrees = 0;
      break;
      
    default:
      break;
    }
  return NULL;
}