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


C++ MemoryWriter::Position方法代码示例

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


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

示例1: EParseError

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);
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: 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));
}
开发者ID:sanyaade-teachings,项目名称:elena-lang,代码行数:33,代码来源:jitlinker.cpp

示例3: allocateVMT

void JITCompiler32 :: allocateVMT(MemoryWriter& vmtWriter, size_t flags, size_t vmtLength)
{
   alignCode(&vmtWriter, VA_ALIGNMENT, false);   

   // create VMT header:
   //   dummy package reference
   vmtWriter.writeDWord(0);

   //   vmt length
   vmtWriter.writeDWord(vmtLength);

   //   vmt flags
   vmtWriter.writeDWord(flags);

   //   dummy class reference
   vmtWriter.writeDWord(0);

   int position = vmtWriter.Position();

   size_t vmtSize = 0;
   if (test(flags, elStandartVMT)) {
      // + VMT length
      vmtSize = vmtLength * sizeof(VMTEntry);
   }

   vmtWriter.writeBytes(0, vmtSize);

   vmtWriter.seek(position);
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例4: 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);
}
开发者ID:bencz,项目名称:cpu-simulator,代码行数:8,代码来源:elenamachine.cpp

示例5: 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);
}
开发者ID:,项目名称:,代码行数:17,代码来源:

示例6: writeTrailItem

inline int writeTrailItem(MemoryWriter& writer, int nonterminal, int next)
{
   int offset = writer.Position();
   writer.writeDWord(nonterminal);
   writer.writeDWord(next);

   return offset;
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例7: allocateConstant

int JITCompiler32 :: allocateConstant(MemoryWriter& writer, size_t objectOffset)
{
   writer.writeBytes(0, objectOffset);

   alignCode(&writer, VA_ALIGNMENT, false);

   return writer.Position() - 4;
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例8: 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);
}
开发者ID:sanyaade-teachings,项目名称:elena-lang,代码行数:9,代码来源:jitlinker.cpp

示例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;
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例10: compileRJump

void ECodesAssembler :: compileRJump(ByteCode code, TokenInfo& token, MemoryWriter& writer, LabelInfo& info, _Module* binary)
{
   writer.writeByte(code);

   int label = 0;

   token.read();

   if (info.labels.exist(token.value)) {
      label = info.labels.get(token.value) - writer.Position() - 8;
   }
   else {
      info.fwdJumps.add(token.value, writer.Position() + 4);
   }
   size_t reference = compileRArg(token, binary);

   writer.writeDWord(reference);
   writer.writeDWord(label);
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例11: compileMccJump

void ECodesAssembler :: compileMccJump(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() - 8;
   }
   else {
      info.fwdJumps.add(token.value, 4 + writer.Position());
   }

   int message = token.readInteger(constants);

   writer.writeDWord(message);
   writer.writeDWord(label);
}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例12: 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++;
   }
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例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++;
   }
}
开发者ID:sanyaade-teachings,项目名称:elena-lang,代码行数:12,代码来源:ecassembler.cpp

示例14: fixVMT

void JITCompiler32 :: fixVMT(MemoryWriter& vmtWriter, void* classClassVAddress, void* packageVAddress, int count, bool virtualMode)
{
   _Memory* image = vmtWriter.Memory();   

   // update class package reference if available
   if (packageVAddress != NULL) {
      int position = vmtWriter.Position();
      vmtWriter.seek(position - 0x10);

      if (virtualMode) {
         vmtWriter.writeRef((ref_t)packageVAddress, 0);
      }
      else vmtWriter.writeDWord((int)packageVAddress);

      vmtWriter.seek(position);
   }

   // update class vmt reference if available
   if (classClassVAddress != NULL) {
      vmtWriter.seek(vmtWriter.Position() - 4);

      if (virtualMode) {                                  
         vmtWriter.writeRef((ref_t)classClassVAddress, 0);
      }
      else vmtWriter.writeDWord((int)classClassVAddress);
   }

   // if in virtual mode mark method addresses as reference
   if (virtualMode) {
      ref_t entryPosition = vmtWriter.Position();
      for (int i = 0 ; i < count ; i++) {
         image->addReference(mskCodeRef, entryPosition + 4);
      
         entryPosition += 8;
      }
   }
}
开发者ID:,项目名称:,代码行数:37,代码来源:

示例15: compileCommand


//.........这里部分代码省略.........
         case bcBCopyF:
         case bcALoadAI:
         case bcALoadFI:
         case bcPushAI:
         case bcOpen:
         case bcAddN:
         case bcMulN:
         case bcDLoadFI:
         case bcDLoadSI:
         case bcDSaveFI:
         case bcDSaveSI:
         case bcRestore:
         case bcReserve:
         case bcALoadBI:
         case bcASaveSI:
         case bcASaveFI:
         case bcNSaveI:
         case bcNLoadI:
         case bcESwapSI:
         case bcBSwapSI:
         case bcAXSaveBI:
         case bcELoadFI:
         case bcELoadSI:
         case bcESaveSI:
         case bcESaveFI:
         case bcShiftN:
         case bcEAddN:
         case bcDSwapSI:
         case bcAJumpI:
         case bcACallI:
         case bcNReadI:
         case bcNWriteI:
            compileICommand(opcode, token, writer);
            break;
         case bcQuitN:
         case bcPopI:
         case bcDCopy:
         case bcECopy:
         case bcSetVerb:
         case bcSetSubj:
         case bcAndN:
         case bcOrN:
         case bcPushN:
            compileNCommand(opcode, token, writer);
            break;
         case bcCopyM:
            compileMCommand(opcode, token, writer, binary);
            break;
         case bcIfB:
         case bcElseB:
         case bcIf:
         case bcElse:
         case bcLess:
         case bcNotLess:
         case bcNext:
         case bcJump:
         case bcHook:
         case bcAddress:
            compileJump(opcode, token, writer, info);
            break;
         case bcIfM:
         case bcElseM:
            compileMccJump(opcode, token, writer, info);
            break;
         case bcIfN:
         case bcElseN:
         case bcLessN:
            compileNJump(opcode, token, writer, info);
            break;
         case bcIfR:
         case bcElseR:
            compileRJump(opcode, token, writer, info, binary);
            break;
         case bcNewN:
            compileCreateCommand(opcode, token, writer, binary);
            break;
         case bcSelectR:
            compileRRCommand(opcode, token, writer, binary);
            break;
         case bcXIndexRM:
            compileRMCommand(opcode, token, writer, binary);
            break;
         default:
            writeCommand(ByteCommand(opcode), writer);
            break;
      }
   }
   else recognized = false;

   if (!recognized) {
      info.labels.add(token.value, writer.Position());

      fixJump(token.value, writer, info);

      writeCommand(ByteCommand(bcNop), writer);

      token.read(":", "':' expected (%d)\n");
   }
   token.read();
}
开发者ID:,项目名称:,代码行数:101,代码来源:


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