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


C++ PClass::has_VMT方法代码示例

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


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

示例1: emit_native_function_call

void UCContext::emit_native_function_call(Function *pfn, CALLFN fn)
{
 Type rt = pfn->return_type();
// *change 1.2.0 Moved from compile_function_call()
// for cdecl-style method imports, 
 if (pfn->is_cdecl() && pfn->is_method()) {
      // push mOP onto exec stack
     emit(PUSH_THIS,0);       
     //  do note that returned objects are by a another hidden arg
     // *fix 1.1.4 The return type must specifically be an _object_, not a pointer to an object!
     if (rt.is_object()) emit(SWAP,0);
 }

 emit(CALLN,DIRECT,NFBlock::create(pfn,fn));

 pfn->fun_block()->data = (void *)fn; // convenient place to keep this!

 // We need to check imported class object ptrs to see if they have a VMT....
 // Any imported class ptrs need their UC VMT patched with CHKVMT
 // *fix 1.1.0 Imported references as well as pointers!
 
 
 if (rt.is_class() && rt.is_ref_or_ptr()) {
    PClass pc = pc = rt.as_class();
	if (pc->imported() && pc->has_VMT()) 
      out(CodeGenerator::instruction_with_pointer(CHKVMT,pc));
 }
 // *add 1.2.9 Sometimes necessary to clear out upper 3bytes of 32-bit boolean values
 else
 if (rt == t_bool) {
   emit(I2B);
 }

}
开发者ID:Artorios,项目名称:rootkit.com,代码行数:34,代码来源:code.cpp

示例2: compile

void UCContext::compile(PExpr ex, int flags)
{
  static Label l1(this),l2(this);
  int tcode,ttype,opcode,op = ex->op();
  PExpr e1 = ex->arg1(), e2 = ex->arg2();
  Type t = ex->type();  
  //t.strip_qualifiers();
  opcode = equiv_op[op];
  if (opcode) {
  // the type of an operator usually tells us what code to emit
  // except in the case of relational ops!
      if (t.is_bool()) t = e1->type(); 
      // *fix 0.9.3 -- ptr check missing!
      if (t.is_double() && ! t.is_pointer())
         opcode = float_equiv[opcode];
      compile(e1);
      if (e2) compile(e2);
      emit(opcode,NONE,0);
      return;
  } 
  tcode = size_code(t);

  // at this point we can remove any non-trival typecast...
  if (passthrough_conversion(t,e1)) e1 = e1->arg1();

  switch(op) {
  case ARRAY: {
    bool is_entry = e1->is_entry();
    int  array_size = is_entry ? Parser::array_size(e1->entry()) : 0;
    if (t.is_pointer()) {
      t.decr_pointer();
      tcode = size_code(t);
    }
    compile(e2);    // put index on stack
    // *add 1.2.5 Check for array bounds, if requested
    if (Parser::debug.range_check && array_size > 1) {
        emit_push_int(array_size);
        emit(CALLN,DIRECT,Builtin::range_check_function());
    }
    if (t.is_class()) {
      int sz = t.size();
      if (sz > sizeof(double)) {
        emit_push_int(sz);
        emit(MUL);    // TOS will be index*sizeof(T)
        compile(e1);  // will give us the addr      
        emit(ADD);
        break;
       } else {
        if (sz == 4) tcode = 2; else tcode = 3;
       }
    } 
    if (is_entry) {
       if (array_size > 1) emit(ADDCC + tcode,e1);
       else emit(ADDPC + tcode,e1);
    } else {
      compile(e1);
      if (tcode==0) emit(ADD); 
      else emit(ADDSW+tcode-1);
    }
  } break;
  case DOT:
     push_object_ptr(this,e1);
     compile(e2,flags);  
     emit(DOS);
   break;
  case CCONTEXT: // constructor call, w/ or w/out object disposal
  { 
      Function *pf = e2->function();
	  PClass pc = pf->class_context();
      compile_function_call(this,FUNCTION,flags,e2,true,e1,pc->has_VMT() ? -1 : 0); 

    // *fix 1.0.0 Any temporaries must be unwound before pushing obj on ODS
	// (only if we are a plain auto var)
      if (t==t_void) Parser::check_temp_context(); 

      // *fix 1.2.0L allow for override (needed for GCC imports) 
      if (Parser::temp_context()->no_auto_dtor() ) emit(DOS);
      else {	        
        if (e1->is_entry()) {
           PEntry pe = e1->entry();
	       if (pc->destructor() == NULL && ! pc->has_VMT()) emit(DOS);
           else {
               // Local 'auto' objects get pushed onto the ODS;
               // *add 1.2.3 Put statically created objects in the static ODL (Object Destructor List)
               bool is_auto = pe->is_stack_relative();
               bool is_direct = pe->is_direct();
               if (! is_auto && ! is_direct) emit(DOS); 
               else if (is_auto) {
                   // *fix 1.2.3 Only set the first object if it _will_ be on the ODS
                   Expressions::set_first_object(e1);  // set as the first object on the stack frame
                   emit_data_instruction(TOSD,(ulong)pc);
               }
               else { // if (is_direct)
                // *change 1.2.9 The static ODS has been retired; instead, we keep
                // program and global ODLs which are evaluated at program close and
                // session close respectively.
                 if (pc->destructor())
                   LoadedModuleList::ODL_add(pe->global_ptr(),pc->destructor());
               } 
           }
//.........这里部分代码省略.........
开发者ID:Artorios,项目名称:rootkit.com,代码行数:101,代码来源:code.cpp


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