Exemplo n.º 1
0
void gendeserialise_element(compile_t* c, reach_type_t* t, bool embed,
  LLVMValueRef ctx, LLVMValueRef ptr)
{
  if(embed || (t->underlying == TK_TUPLETYPE))
  {
    // Embedded field or tuple, deserialise in place.
    deserialise(c, t, ctx, ptr);
  } else if(t->primitive != NULL) {
    // Machine word, already copied.
  } else {
    // Lookup the pointer and write that.
    LLVMValueRef value = LLVMBuildLoad(c->builder, ptr, "");

    LLVMValueRef args[3];
    args[0] = ctx;
    args[1] = (t->desc != NULL) ?
      LLVMBuildBitCast(c->builder, t->desc, c->descriptor_ptr, "") :
      LLVMConstNull(c->descriptor_ptr);
    args[2] = LLVMBuildPtrToInt(c->builder, value, c->intptr, "");
    LLVMValueRef object = gencall_runtime(c, "pony_deserialise_offset",
      args, 3, "");

    object = LLVMBuildBitCast(c->builder, object, t->use_type, "");
    LLVMBuildStore(c->builder, object, ptr);
  }
}
Exemplo n.º 2
0
std::shared_ptr<pSensor> iRobot::readData()
{
    byte type;
    //std::cout << "Waiting for data" << std::endl;
    if (readStable(&type,1)!=ERROR::NONE){
        std::cout << std::strerror(errno) <<std::endl;
        std::cout << "Receive disconnected"<<std::endl;
        return std::shared_ptr<pSensor>();
    }

    //create the packet...
    auto pkt = pSensor::getSensorPacketManaged(type);
    if (pkt == 0){
        std::cout << "No implemented packet, out of sync..." << type<<std::endl;
        return std::shared_ptr<pSensor>();
    }

    int length = pkt->getLength();
    if (length == -1){
        //return the packet... it deals with itself...
        return pkt;
    }
    byte data[length];
    if (readStable(data,length)==ERROR::NONE){
        if (pkt->deserialise(type,data)!=ERROR::NONE){
            return std::shared_ptr<pSensor>();
        }
        return pkt;
    }
    return std::shared_ptr<pSensor>();
}
void individual_to_safety_solution_deserialisert::operator()(
    safety_goto_solutiont &result, const irept &sdu) const
{
  program_individualt ind;
  deserialise(ind, sdu);
  invariant_variable_idst ids;
  const symbol_tablet &st=prog.st;
  get_invariant_variable_ids(st, ids);
  create_safety_solution(result, st, prog.gf, ind, ids, info_fac);
}
Exemplo n.º 4
0
static void check_serialise_deserialise(const Block &block)
{
	std::stringstream ss;

	// Write the test data to the memory stream
	serialise(ss, block);

	// Read it back, make sure input and output data are equal
	check_equal(block, deserialise(ss));
}
Exemplo n.º 5
0
TEST(binnf, python_communication)
{
	// Open the python loopback as a subprocess
	Process proc("python", {Resources::PYNN_BINNF_LOOPBACK.open()});

	// Generate a test data block
	const Block block_in_1 = generate_test_matrix_block();
	const Block block_in_2 = generate_test_log_block();

	// Send the data block to python
	serialise(proc.child_stdin(), block_in_1);
	serialise(proc.child_stdin(), block_in_2);
	serialise(proc.child_stdin(), block_in_2);
	serialise(proc.child_stdin(), block_in_1);
	serialise(proc.child_stdin(), block_in_2);
	serialise(proc.child_stdin(), block_in_2);
	serialise(proc.child_stdin(), block_in_1);
	serialise(proc.child_stdin(), block_in_1);
	proc.close_child_stdin();

	// Read it back, expect the deserialisation to be successful
	try {
		check_equal(block_in_1, deserialise(proc.child_stdout()));
		check_equal(block_in_2, deserialise(proc.child_stdout()));
		check_equal(block_in_2, deserialise(proc.child_stdout()));
		check_equal(block_in_1, deserialise(proc.child_stdout()));
		check_equal(block_in_2, deserialise(proc.child_stdout()));
		check_equal(block_in_2, deserialise(proc.child_stdout()));
		check_equal(block_in_1, deserialise(proc.child_stdout()));
		check_equal(block_in_1, deserialise(proc.child_stdout()));
	}
	catch (BinnfDecodeException &e) {
		// Most likely there is an error message
		char buf[4096];
		while (proc.child_stderr().good()) {
			proc.child_stderr().read(buf, 4096);
			std::cout.write(buf, proc.child_stderr().gcount());
		}
		EXPECT_TRUE(false);
	}

	// Make sure the Python code does not crash
	EXPECT_EQ(0, proc.wait());
}
Exemplo n.º 6
0
void 
Serialiser::deserialise(OrderedTask& data)
{
  data.clear();
  data.set_factory(task_factory_type());
  data.reset();

  OrderedTaskBehaviour beh = data.get_ordered_task_behaviour();
  deserialise(beh);
  data.set_ordered_task_behaviour(beh);

  DataNode* point_node;
  unsigned i=0;
  while ((point_node = m_node.get_child_by_name(_T("Point"),i)) != NULL) {
    Serialiser pser(*point_node);
    pser.deserialise_point(data);
    delete point_node;
    i++;
  }
}
Exemplo n.º 7
0
int main(int argc, char *argv[])
{
    int i;
	for(i = 1; i < argc && (argv[i][0] == '-'); i++)
    {
		if(i == argc)
        {
			return (-1);
		}
	}

    vfs = new loss::VirtualFileSystem();
    ramfs = new loss::RamFileSystem();
    vfs->root_filesystem(ramfs);
    file_to_open = argv[i];

    log_file.open("./fuse.log");
    log_file << "Attempting to open: " << file_to_open << " as hdd\n";

    {
        std::ifstream input(file_to_open);
        loss::RamFileSystemDeserialise deserialise(input, ramfs);
        deserialise.load();
        input.close();
    }

	for(; i < argc; i++)
    {
		argv[i] = argv[i+1];
	}
	argc--;

    log_file << "Starting FUSE main\n";
    auto result = fuse_main(argc, argv, &hello_oper, NULL);
    
    log_file << "Shutting down FUSE main\n";

    delete vfs;

    return result;
}
Exemplo n.º 8
0
static void make_deserialise(compile_t* c, reach_type_t* t)
{
  // Generate the deserialise function.
  t->deserialise_fn = codegen_addfun(c, genname_deserialise(t->name),
    c->trace_type);

  codegen_startfun(c, t->deserialise_fn, NULL, NULL);
  LLVMSetFunctionCallConv(t->deserialise_fn, LLVMCCallConv);
  LLVMSetLinkage(t->deserialise_fn, LLVMExternalLinkage);

  LLVMValueRef ctx = LLVMGetParam(t->deserialise_fn, 0);
  LLVMValueRef arg = LLVMGetParam(t->deserialise_fn, 1);

  LLVMValueRef object = LLVMBuildBitCast(c->builder, arg, t->structure_ptr,
    "");

  // At this point, the serialised contents have been copied to the allocated
  // object.
  deserialise(c, t, ctx, object);

  LLVMBuildRetVoid(c->builder);
  codegen_finishfun(c);
}
Exemplo n.º 9
0
	GammaInterval(std::istream & in)
	{
		deserialise(in);
	}
Exemplo n.º 10
0
			/**
			 * constructor from stream
			 *
			 * @param istr input stream
			 **/
			DuplicationMetrics(std::istream & in)
			{
				deserialise(in);
			}
Exemplo n.º 11
0
				AlignmentFile(std::istream & in)
				: putbackslotactive(false)
				{
					deserialise(in);
					alre = 0;
				}
Exemplo n.º 12
0
				AlignmentFile(std::istream & in, uint64_t & s)
				: putbackslotactive(false)
				{
					s += deserialise(in);
					alre = 0;
				}
set<tile_t>
CompressedBitset::decompress() const {
  auto_ptr<tree_entry> root = deserialise(bytes);
  return unbuild_crit_bit_tree(root, sizeof(tile_t) * 8);
}
Exemplo n.º 14
0
	CoordinatePair(std::istream & in)
	{
		deserialise(in);
	}
Exemplo n.º 15
0
				Tandem(std::istream & in)
				{
					deserialise(in);
				}
Exemplo n.º 16
0
				OverlapInfo(std::istream & in)
				{
					deserialise(in);
				}
Exemplo n.º 17
0
			PLCPBitDecoder(std::istream & in)
			{
				deserialise(in);
			}
Exemplo n.º 18
0
			CommandContainer(std::istream & in)
			{
				deserialise(in);
			}
Exemplo n.º 19
0
				IndexBase(std::istream & in)
				{
					deserialise(in);
				}