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


C++ bytes::push_back方法代码示例

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


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

示例1: pushLocation

static void pushLocation(bytes& o_code, uint32_t _locationValue)
{
	o_code.push_back((byte)Instruction::PUSH4);
	o_code.resize(o_code.size() + 4);
	bytesRef r(&o_code[o_code.size() - 4], 4);
	toBigEndian(_locationValue, r);
}
开发者ID:AcriCAA,项目名称:cpp-ethereum,代码行数:7,代码来源:Instruction.cpp

示例2: push

void Packet::push(bytes &arr, int &index, byte data) {
    if (arr.size() > (unsigned) index) {
        arr[index++] = data;
    } else {
        arr.push_back(data);
        index++;
    }
}
开发者ID:jed1,项目名称:smrtlink,代码行数:8,代码来源:Packet.cpp

示例3: appendCode

static void appendCode(bytes& o_code, vector<unsigned>& o_locs, bytes _code, vector<unsigned>& _locs)
{
	o_locs.reserve(o_locs.size() + _locs.size());
	for (auto i: _locs)
	{
		increaseLocation(_code, i, (unsigned)o_code.size());
		o_locs.push_back(i + (unsigned)o_code.size());
	}
	o_code.reserve(o_code.size() + _code.size());
	for (auto i: _code)
		o_code.push_back(i);
}
开发者ID:AcriCAA,项目名称:cpp-ethereum,代码行数:12,代码来源:Instruction.cpp

示例4: pushLiteral

static unsigned pushLiteral(bytes& o_code, u256 _literalValue)
{
	unsigned br = max<unsigned>(1, bytesRequired(_literalValue));
	o_code.push_back((byte)Instruction::PUSH1 + br - 1);
	o_code.resize(o_code.size() + br);
	for (unsigned i = 0; i < br; ++i)
	{
		o_code[o_code.size() - 1 - i] = (byte)(_literalValue & 0xff);
		_literalValue >>= 8;
	}
	return br + 1;
}
开发者ID:AcriCAA,项目名称:cpp-ethereum,代码行数:12,代码来源:Instruction.cpp

示例5: compileLispFragment

static int compileLispFragment(char const*& d, char const* e, bool _quiet, bytes& o_code, vector<unsigned>& o_locs, map<string, unsigned>& _vars)
{
	std::map<std::string, Instruction> const c_arith = { { "+", Instruction::ADD }, { "-", Instruction::SUB }, { "*", Instruction::MUL }, { "/", Instruction::DIV }, { "%", Instruction::MOD } };
	std::map<std::string, pair<Instruction, bool>> const c_binary = { { "<", { Instruction::LT, false } }, { "<=", { Instruction::GT, true } }, { ">", { Instruction::GT, false } }, { ">=", { Instruction::LT, true } }, { "=", { Instruction::EQ, false } }, { "!=", { Instruction::EQ, true } } };
	std::map<std::string, Instruction> const c_unary = { { "!", Instruction::NOT } };
	std::set<char> const c_allowed = { '+', '-', '*', '/', '%', '<', '>', '=', '!' };

	bool exec = false;
	int outs = 0;
	bool seq = false;

	while (d != e)
	{
		// skip to next token
		for (; d != e && !isalnum(*d) && *d != '(' && *d != ')' && *d != '{' && *d != '}' && *d != '_' && *d != '"' && *d != '@' && *d != '[' && !c_allowed.count(*d) && *d != ';'; ++d) {}
		if (d == e)
			break;

		switch (*d)
		{
		case ';':
			for (; d != e && *d != '\n'; ++d) {}
			break;
		case '(':
			exec = true;
			++d;
			break;
		case '{':
			++d;
			while (d != e)
			{
				bytes codes;
				vector<unsigned> locs;
				outs = 0;
				int o;
				if ((o = compileLispFragment(d, e, _quiet, codes, locs, _vars)) > -1)
				{
					for (int i = 0; i < outs; ++i)
						o_code.push_back((byte)Instruction::POP);	// pop additional items off stack for the previous item (final item's returns get left on).
					outs = o;
					appendCode(o_code, o_locs, codes, locs);
				}
				else
					break;
			}
			seq = true;
			break;
		case '}':
			if (seq)
			{
				++d;
				return outs;
			}
			return -1;
		case ')':
			if (exec)
			{
				++d;
				return outs;
			}
			else
				// unexpected - return false as we don't know what to do with it.
				return -1;

		case '@':
		{
			if (exec)
				return -1;
			bool store = false;
			++d;
			if (*d == '@')
			{
				++d;
				store = true;
			}
			bytes codes;
			vector<unsigned> locs;
			if (compileLispFragment(d, e, _quiet, codes, locs, _vars) != 1)
				return -1;
			while (d != e && isspace(*d))
				++d;
			appendCode(o_code, o_locs, codes, locs);
			o_code.push_back((byte)(store ? Instruction::SLOAD : Instruction::MLOAD));
			return 1;
		}
		case '[':
		{
			if (exec)
				return -1;
			bool store = false;
			++d;
			if (*d == '[')
			{
				++d;
				store = true;
			}
			bytes codes;
			vector<unsigned> locs;
			if (compileLispFragment(d, e, _quiet, codes, locs, _vars) != 1)
				return -1;
//.........这里部分代码省略.........
开发者ID:AcriCAA,项目名称:cpp-ethereum,代码行数:101,代码来源:Instruction.cpp


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