Exemplo n.º 1
0
  protobuf::StackFrame* getProtobufStackFrame(JS::ubi::StackFrame& frame) {
    MOZ_ASSERT(frame,
               "null frames should be represented as the lack of a serialized "
               "stack frame");

    auto id = frame.identifier();
    auto protobufStackFrame = MakeUnique<protobuf::StackFrame>();
    if (!protobufStackFrame)
      return nullptr;

    if (framesAlreadySerialized.has(id)) {
      protobufStackFrame->set_ref(id);
      return protobufStackFrame.release();
    }

    auto data = MakeUnique<protobuf::StackFrame_Data>();
    if (!data)
      return nullptr;

    data->set_id(id);
    data->set_line(frame.line());
    data->set_column(frame.column());
    data->set_issystem(frame.isSystem());
    data->set_isselfhosted(frame.isSelfHosted());

    auto source = MakeUnique<std::string>(frame.sourceLength() * sizeof(char16_t),
                                          '\0');
    if (!source)
      return nullptr;
    auto buf = const_cast<char16_t*>(reinterpret_cast<const char16_t*>(source->data()));
    frame.source(RangedPtr<char16_t>(buf, frame.sourceLength()),
                 frame.sourceLength());
    data->set_allocated_source(source.release());

    auto nameLength = frame.functionDisplayNameLength();
    if (nameLength > 0) {
      auto functionDisplayName = MakeUnique<std::string>(nameLength * sizeof(char16_t),
                                                         '\0');
      if (!functionDisplayName)
        return nullptr;
      auto buf = const_cast<char16_t*>(reinterpret_cast<const char16_t*>(functionDisplayName->data()));
      frame.functionDisplayName(RangedPtr<char16_t>(buf, nameLength), nameLength);
      data->set_allocated_functiondisplayname(functionDisplayName.release());
    }

    auto parent = frame.parent();
    if (parent) {
      auto protobufParent = getProtobufStackFrame(parent);
      if (!protobufParent)
        return nullptr;
      data->set_allocated_parent(protobufParent);
    }

    protobufStackFrame->set_allocated_data(data.release());

    if (!framesAlreadySerialized.put(id))
      return nullptr;

    return protobufStackFrame.release();
  }
	void Table::set_table(std::string const& name)
	{
		if(name.empty())
		{
			Lua_table_ref t;
			m_table_ref.swap(t);
			return;
		}
		if(!m_table_ref.m_lua)return;

		lua_getglobal(m_table_ref.m_lua,  name.c_str() );
		if(lua_type(m_table_ref.m_lua, -1) != LUA_TTABLE)
		{
			lua_pop(m_table_ref.m_lua, 1);
			lua_getfield(m_table_ref.m_lua, LUA_REGISTRYINDEX, name.c_str() );
			if(lua_type(m_table_ref.m_lua, -1) != LUA_TTABLE)
			{
				lua_pop(m_table_ref.m_lua,  1);
				Lua_table_ref t;
				m_table_ref.swap(t);
				return;
			}
		}
		set_ref(m_table_ref.m_lua, luaL_ref(m_table_ref.m_lua, LUA_REGISTRYINDEX));
	}
Exemplo n.º 3
0
Arquivo: _cref.c Projeto: ehershey/pd
int cmd_cref( string a )
{
  mixed ob;
  object new_ob;
  string name, num;

  seteuid( geteuid( previous_object() ) );

  if( !a ) a = "#default";
  ob = ref_ob( a );
  if( !objectp( ob ) )
  {
    notify_fail( wrap( "Could not identify " + identify( ob ) +
      " as an object." ) );
    return 0;
  }
  name = file_name( ob );
  if( sscanf( name, "%s#%s", ob, num ) < 2 )
    ob = name;
  if( catch( new_ob = new( ob ) ) )
    { notify_fail( "Could not clone " + ob + "\n" ); return 0; }
  write( "CLONE: You have created " + identify( new_ob ) + "\n" );
  if( new_ob-> move( this_player() ) != MOVE_OK )
    new_ob-> move( environment( this_player() ) );
  set_ref( 0, new_ob );
  return 1;
}
Exemplo n.º 4
0
 void collectable::clean()
 {
     generate_output("Definitely garbage ", id);
     int n = out_refs.size();
     for (int i = 0; i < n; i++)
     {
         set_ref(i, hpx::naming::invalid_id);
     }
 }
Exemplo n.º 5
0
void test_refs_are_destruction_safe()
{
    Branch branch;
    Term* a = branch.compile("a = 1");
    caValue ref;
    set_ref(&ref, a);
    test_assert(as_ref(&ref) == a);
    clear_branch(&branch);
    test_assert(as_ref(&ref) == NULL);
}
Exemplo n.º 6
0
int cmd_sc( string a ) 
{
  mixed ob;
  object obj;
  int i;

  seteuid( geteuid( previous_object() ) );

  if( !a ) a = "here";
  ob = ref_ob( a );
  if( !objectp( ob ) )
  {
    notify_fail( wrap( "Could not identify " + identify( ob ) + 
      " as an object." ) );
    return 0;
  }
  write( wrap( "Deep Scanning: " + identify( ob ) + " EUID(" + geteuid( ob ) +
    ") UID(" + getuid( ob ) + ")" ) );
  sc_object( ob, "  " );
  set_ref( "default", ob );
  set_ref( "sc", deep_inventory( ob ) );
  return 1;
}
Exemplo n.º 7
0
Arquivo: _move.c Projeto: ehershey/pd
int cmd_move( string a )
{
mixed o1, o2;
  string str;
  int ret;

    if(member_group(geteuid(previous_object()), "ambassador")) return 0;
  if( !a || ( sscanf( a, "%s to %s", o1, o2 ) < 2 ) )
    { notify_fail( SYNTAX ); return 0; }

  seteuid( geteuid( previous_object() ) );

  o1 = ref_ob( o1 );
  if( !objectp( o1 ) )
  {
    notify_fail( wrap( "Could not identify " + identify( o1 ) +
      " as an object." ) );
    return 0;
  }
  o2 = ref_ob( o2 );
  if( !objectp( o2 ) )
  {
    notify_fail( wrap( "Could not identify " + identify( o2 ) +
     " as an object." ) );
    return 0;
  }
  set_ref( 0, o2 );
  write( wrap( "Moving " + identify( o1 ) + " to " + identify( o2 ) + "..." ) );
  ret = o1-> move( o2 );
  switch( ret )
  {
    case MOVE_OK:		str = "Move OK.\n"; break;
    case MOVE_NOT_ALLOWED:	str = "Move not allowed.\n"; break;
    case MOVE_NO_ROOM:		str = "No room in object2 for object1\n"; break;
    case MOVE_DESTRUCTED:	str = "Move destructed\n"; break;
    case MOVE_NO_DEST:		str = "object2 is not a destination\n"; break;
#ifdef MOVE_TOO_HEAVY
    case MOVE_TOO_HEAVY:	str = "object1 too heavy for object2\n"; break;
#endif /* MOVE_TOO_HEAVY */
#ifdef MOVE_DOOR_CLOSED
    case MOVE_DOOR_CLOSED:	str = "The door is closed.\n"; break;
#endif /* MOVE_DOOR_CLOSED */
    default: str = "Error: move return code " + ret + "\n"; break;
  }
  if( ret == MOVE_OK ) { write( str ); return 1; }
  notify_fail( str ); 
  return 0;
}
Exemplo n.º 8
0
int main(int argc, char** argv) {
  gv_set_ref(0, 0, 0);
  set_ref(0., 0., 0.);
  int i = 0;
  while (i<NB_STEP) {
    int32_t sp_i = get_sp(i);
    //    gv_update_ref_from_z_sp(sp_i);
    gv_update_ref_from_zd_sp(sp_i);
    //    z_sp = BOOZ_FLOAT_OF_INT(sp_i, IPOS_FRAC);
    //    update_ref_from_z();
    zd_sp = BOOZ_FLOAT_OF_INT(sp_i, ISPEED_RES);
    update_ref_from_zd();
    print_ref(i);
    i++;
  }


  return 0;
}
Exemplo n.º 9
0
  protobuf::StackFrame* getProtobufStackFrame(JS::ubi::StackFrame& frame,
                                              size_t depth = 1) {
    // NB: de-duplicated string properties must be written in the same order
    // here as they are read in `HeapSnapshot::saveStackFrame` or else indices
    // in references to already serialized strings will be off.

    MOZ_ASSERT(frame,
               "null frames should be represented as the lack of a serialized "
               "stack frame");

    auto id = frame.identifier();
    auto protobufStackFrame = MakeUnique<protobuf::StackFrame>();
    if (!protobufStackFrame)
      return nullptr;

    if (framesAlreadySerialized.has(id)) {
      protobufStackFrame->set_ref(id);
      return protobufStackFrame.release();
    }

    auto data = MakeUnique<protobuf::StackFrame_Data>();
    if (!data)
      return nullptr;

    data->set_id(id);
    data->set_line(frame.line());
    data->set_column(frame.column());
    data->set_issystem(frame.isSystem());
    data->set_isselfhosted(frame.isSelfHosted());

    auto dupeSource = TwoByteString::from(frame.source());
    if (!attachTwoByteString(dupeSource,
                             [&] (std::string* source) { data->set_allocated_source(source); },
                             [&] (uint64_t ref) { data->set_sourceref(ref); }))
    {
      return nullptr;
    }

    auto dupeName = TwoByteString::from(frame.functionDisplayName());
    if (dupeName.isNonNull()) {
      if (!attachTwoByteString(dupeName,
                               [&] (std::string* name) { data->set_allocated_functiondisplayname(name); },
                               [&] (uint64_t ref) { data->set_functiondisplaynameref(ref); }))
      {
        return nullptr;
      }
    }

    auto parent = frame.parent();
    if (parent && depth < HeapSnapshot::MAX_STACK_DEPTH) {
      auto protobufParent = getProtobufStackFrame(parent, depth + 1);
      if (!protobufParent)
        return nullptr;
      data->set_allocated_parent(protobufParent);
    }

    protobufStackFrame->set_allocated_data(data.release());

    if (!framesAlreadySerialized.put(id))
      return nullptr;

    return protobufStackFrame.release();
  }