本文整理汇总了C++中MemoryWriter类的典型用法代码示例。如果您正苦于以下问题:C++ MemoryWriter类的具体用法?C++ MemoryWriter怎么用?C++ MemoryWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MemoryWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeReference
void JITLinker::ReferenceHelper :: writeReference(MemoryWriter& writer, ref_t reference, size_t disp, _Module* module)
{
ref_t mask = reference & mskAnyRef;
ref_t refID = reference & ~mskAnyRef;
//// check if it is a constant, resolve it immediately
//if (mask == mskLinkerConstant) {
// writer.writeDWord(getLinkerConstant(refID));
// return;
//}
if (!module)
module = _module;
ref_t position = writer.Position();
writer.writeDWord(disp);
// vmt entry offset should be resolved later
if (mask == mskVMTEntryOffset) {
_references->add(position, RefInfo(reference, module));
return;
}
// try to resolve immediately
void* vaddress = _owner->_loader->resolveReference(
_owner->_loader->retrieveReference(module, refID, mask), mask);
if (vaddress != LOADER_NOTLOADED) {
resolveReference(writer.Memory(), position, (ref_t)vaddress, mask, _owner->_virtualMode);
}
// or resolve later
else _references->add(position, RefInfo(reference, module));
}
示例2: buildDerivationTree
int CFParser :: buildDerivationTree(_ScriptReader& reader, size_t startRuleId, MemoryWriter& writer)
{
DerivationQueue predictions;
predictions.push(DerivationItem(startRuleId, 0, -1));
ScriptBookmark bm;
while (predictions.Count() > 0) {
predictions.push(DerivationItem(0));
bm = reader.read();
int terminalOffset = writer.Position();
writer.write(&bm, sizeof(ScriptBookmark));
DerivationItem current = predictions.pop();
while (current.ruleId != 0) {
if (current.ruleId == -1) {
return current.trace;
}
predict(predictions, current, reader, bm, terminalOffset, writer);
current = predictions.pop();
}
}
throw EParseError(bm.column, bm.row);
}
示例3: encode
void TriangleEncoder::encode(
const vector<TriangleVertexInfo>& triangle_vertex_infos,
const vector<GVector3>& triangle_vertices,
const vector<size_t>& triangle_indices,
const size_t item_begin,
const size_t item_count,
MemoryWriter& writer)
{
for (size_t i = 0; i < item_count; ++i)
{
const size_t triangle_index = triangle_indices[item_begin + i];
const TriangleVertexInfo& vertex_info = triangle_vertex_infos[triangle_index];
writer.write(static_cast<uint32>(vertex_info.m_motion_segment_count));
if (vertex_info.m_motion_segment_count == 0)
{
writer.write(
GTriangleType(
triangle_vertices[vertex_info.m_vertex_index + 0],
triangle_vertices[vertex_info.m_vertex_index + 1],
triangle_vertices[vertex_info.m_vertex_index + 2]));
}
else
{
writer.write(
&triangle_vertices[vertex_info.m_vertex_index],
(vertex_info.m_motion_segment_count + 1) * 3 * sizeof(GVector3));
}
}
}
示例4: init
FMT_FUNC void SystemError::init(
int err_code, CStringRef format_str, ArgList args) {
error_code_ = err_code;
MemoryWriter w;
format_system_error(w, err_code, format(format_str, args));
std::runtime_error &base = *this;
base = std::runtime_error(w.str());
}
示例5: format
FMT_FUNC void fmt::WindowsError::init(
int err_code, StringRef format_str, ArgList args) {
error_code_ = err_code;
MemoryWriter w;
internal::format_windows_error(w, err_code, format(format_str, args));
std::runtime_error &base = *this;
base = std::runtime_error(w.str());
}
示例6: writeReference
void Instance::ImageReferenceHelper :: writeReference(MemoryWriter& writer, ref_t reference, size_t disp, _Module* module)
{
size_t pos = reference & ~mskAnyRef;
if (test(reference, mskRelCodeRef)) {
writer.writeDWord(pos - writer.Position() - 4);
}
else writer.writeDWord((test(reference, mskRDataRef) ? _statBase : _codeBase) + pos + disp);
}
示例7: writeTrailItem
inline int writeTrailItem(MemoryWriter& writer, int nonterminal, int next)
{
int offset = writer.Position();
writer.writeDWord(nonterminal);
writer.writeDWord(next);
return offset;
}
示例8: allocateConstant
int JITCompiler32 :: allocateConstant(MemoryWriter& writer, size_t objectOffset)
{
writer.writeBytes(0, objectOffset);
alignCode(&writer, VA_ALIGNMENT, false);
return writer.Position() - 4;
}
示例9: writeDerivationItem
inline int writeDerivationItem(MemoryWriter& writer, int key, int terminal, int trace)
{
int offset = writer.Position();
writer.writeDWord(key);
writer.writeDWord(terminal);
writer.writeDWord(trace);
return offset;
}
示例10: loadMethod
size_t JITLinker :: loadMethod(ReferenceHelper& refHelper, MemoryReader& reader, MemoryWriter& writer)
{
size_t position = writer.Position();
// method just in time compilation
_compiler->compileProcedure(refHelper, reader, writer);
return _virtualMode ? position : (size_t)writer.Memory()->get(position);
}
示例11: writeCommand
void ECodesAssembler :: writeCommand(ByteCommand command, MemoryWriter& writer)
{
writer.writeByte(command.code);
if (command.code > MAX_SINGLE_ECODE) {
writer.writeDWord(command.argument);
}
if (command.code > MAX_DOUBLE_ECODE) {
writer.writeDWord(command.additional);
}
}
示例12: writeCommand
void ECodesAssembler :: writeCommand(ByteCommand command, MemoryWriter& writer)
{
writer.writeByte(command.code);
if (command.code >= 0x20) {
writer.writeDWord(command.argument);
}
if (command.code >= 0xE0) {
writer.writeDWord(command.additional);
}
}
示例13: fixJump
void ECodesAssembler :: fixJump(const wchar16_t* label, MemoryWriter& writer, LabelInfo& info)
{
_Memory* code = writer.Memory();
Map<const wchar16_t*, int>::Iterator it = info.fwdJumps.start();
while (!it.Eof()) {
if (StringHelper::compare(it.key(), label)) {
(*code)[*it] = writer.Position();
}
it++;
}
}
示例14: fixJump
void ECodesAssembler :: fixJump(ident_t label, MemoryWriter& writer, LabelInfo& info)
{
_Memory* code = writer.Memory();
Map<ident_t, int>::Iterator it = info.fwdJumps.start();
while (!it.Eof()) {
if (label.compare(it.key())) {
(*code)[*it] = writer.Position() - *it - 4;
}
it++;
}
}
示例15: compileJump
void ECodesAssembler :: compileJump(ByteCode code, TokenInfo& token, MemoryWriter& writer, LabelInfo& info)
{
writer.writeByte(code);
int label = 0;
token.read();
if (info.labels.exist(token.value)) {
label = info.labels.get(token.value) - writer.Position() - 4;
}
else {
info.fwdJumps.add(token.value, writer.Position());
}
writer.writeDWord(label);
}