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


C++ MethodTable类代码示例

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


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

示例1: FCIMPL1

FCIMPL1(void, ArrayNative::Initialize, ArrayBase* array)
{
    FCALL_CONTRACT;

    if (array == NULL)
    {
        FCThrowVoid(kNullReferenceException);
    }


    MethodTable* pArrayMT = array->GetMethodTable();

    TypeHandle thElem = pArrayMT->GetApproxArrayElementTypeHandle();
    if (thElem.IsTypeDesc())
        return;

    MethodTable * pElemMT = thElem.AsMethodTable();
    if (!pElemMT->HasDefaultConstructor() || !pElemMT->IsValueType())
        return;

    ARRAYBASEREF arrayRef (array);
    HELPER_METHOD_FRAME_BEGIN_1(arrayRef);

    ArrayInitializeWorker(&arrayRef, pArrayMT, pElemMT);

    HELPER_METHOD_FRAME_END();
}
开发者ID:AndreGleichner,项目名称:coreclr,代码行数:27,代码来源:arraynative.cpp

示例2: MethodTable

/* Get method specifications */
const MethodTable& RateMatrix::getMethods(void) const {
    
    static MethodTable    methods                     = MethodTable(); 
    static bool           methodsSet                  = false;
    
    if ( methodsSet == false ) {
        
        // add method for call "x[]" as a function
        ArgumentRules* squareBracketArgRules = new ArgumentRules();
        squareBracketArgRules->push_back( new ArgumentRule( "index" , true, Natural::getClassTypeSpec() ) );
        methods.addFunction("[]",  new MemberProcedure( ModelVector<RealPos>::getClassTypeSpec(), squareBracketArgRules) );
        
        
        // add method for call "x[]" as a function
        ArgumentRules* sizeArgRules = new ArgumentRules();
        methods.addFunction("size",  new MemberProcedure( Natural::getClassTypeSpec(), sizeArgRules) );
        
        // necessary call for proper inheritance
        methods.setParentTable( &ModelObject<RevBayesCore::RateMatrix>::getMethods() );
        methodsSet = true;
    }
    
    
    return methods;
}
开发者ID:SylerWang,项目名称:RevBayes,代码行数:26,代码来源:RlRateMatrix.cpp

示例3: CallFinalizer

void CallFinalizer(Object* obj)
{
    STATIC_CONTRACT_THROWS;
    STATIC_CONTRACT_GC_TRIGGERS;
    STATIC_CONTRACT_MODE_COOPERATIVE;

    MethodTable     *pMT = obj->GetMethodTable();
    STRESS_LOG2(LF_GC, LL_INFO1000, "Finalizing object %p MT %pT\n", obj, pMT);
    LOG((LF_GC, LL_INFO1000, "Finalizing " LOG_OBJECT_CLASS(obj)));

    _ASSERTE(GetThread()->PreemptiveGCDisabled());
    // if we don't have a class, we can't call the finalizer
    // if the object has been marked run as finalizer run don't call either
    if (pMT)
    {
        if (!((obj->GetHeader()->GetBits()) & BIT_SBLK_FINALIZER_RUN))
        {

            _ASSERTE(obj->GetMethodTable() == pMT);
            _ASSERTE(pMT->HasFinalizer() || pMT->IsTransparentProxy());

            LogFinalization(obj);
            MethodTable::CallFinalizer(obj);
        }
        else
        {
            //reset the bit so the object can be put on the list 
            //with RegisterForFinalization
            obj->GetHeader()->ClrBit (BIT_SBLK_FINALIZER_RUN);
        }
    }
}
开发者ID:alsemenn,项目名称:coreclr,代码行数:32,代码来源:finalizerthread.cpp

示例4: MethodTable

/* Get method specifications */
const MethodTable& ParallelMcmcmc::getMethods(void) const {
    
    static MethodTable   methods    = MethodTable();
    static bool          methodsSet = false;
    
    if ( methodsSet == false ) {
        ArgumentRules* runArgRules = new ArgumentRules();
        runArgRules->push_back( new ArgumentRule("generations", true, Natural::getClassTypeSpec()) );
        methods.addFunction("run", new MemberProcedure( RlUtils::Void, runArgRules) );
        
        ArgumentRules* burninArgRules = new ArgumentRules();
        burninArgRules->push_back( new ArgumentRule("generations", true, Natural::getClassTypeSpec()) );
        burninArgRules->push_back( new ArgumentRule("tuningInterval", true, Natural::getClassTypeSpec()) );
        methods.addFunction("burnin", new MemberProcedure( RlUtils::Void, burninArgRules) );
        
        ArgumentRules* operatorSummaryArgRules = new ArgumentRules();
        methods.addFunction("operatorSummary", new MemberProcedure( RlUtils::Void, operatorSummaryArgRules) );
        
        // necessary call for proper inheritance
        methods.setParentTable( &RevObject::getMethods() );
        methodsSet = true;
    }
    
    return methods;
}
开发者ID:SylerWang,项目名称:RevBayes,代码行数:26,代码来源:RlParallelMcmcmc.cpp

示例5: class_info

  void MethodTable::Info::show(STATE, Object* self, int level) {
    MethodTable* tbl = as<MethodTable>(self);
    size_t size = tbl->bins()->to_native();

    if(size == 0) {
      class_info(state, self, true);
      return;
    }

    class_info(state, self);
    std::cout << ": " << size << std::endl;
    indent(++level);
    for(size_t i = 0; i < size; i++) {
      MethodTableBucket* entry = try_as<MethodTableBucket>(tbl->values()->at(state, i));

      while(entry) {
       if(Symbol* sym = try_as<Symbol>(entry->name())) {
          std::cout << ":" << sym->debug_str(state);
        } else if(Fixnum* fix = try_as<Fixnum>(entry->name())) {
          std::cout << fix->to_native();
        }
        entry = try_as<MethodTableBucket>(entry->next());
      }
      if(i < size - 1) std::cout << ", ";
    }
    std::cout << std::endl;
    close_body(level);
  }
开发者ID:Energy0124,项目名称:rubinius,代码行数:28,代码来源:methodtable.cpp

示例6: lg

  MethodTable* MethodTable::duplicate(STATE) {
    size_t size, i;
    MethodTable* dup = 0;

    utilities::thread::SpinLock::LockGuard lg(lock_);

    size = bins_->to_native();
    dup = MethodTable::create(state, size);

    // Allow for subclassing.
    dup->klass(state, class_object(state));

    size_t num = bins_->to_native();

    MethodTableBucket* entry = 0;

    for(i = 0; i < num; i++) {
      entry = try_as<MethodTableBucket>(values_->at(state, i));

      while(entry) {
        dup->store(state, entry->name(), entry->method(), entry->visibility());
        entry = try_as<MethodTableBucket>(entry->next());
      }
    }

    return dup;
  }
开发者ID:Energy0124,项目名称:rubinius,代码行数:27,代码来源:methodtable.cpp

示例7: G

  MethodTable* MethodTable::create(STATE, size_t size) {
    MethodTable *tbl;

    tbl = state->memory()->new_object<MethodTable>(state, G(method_table));
    tbl->setup(state, size);

    return tbl;
  }
开发者ID:JesseChavez,项目名称:rubinius,代码行数:8,代码来源:method_table.cpp

示例8: create

  MethodTable* MethodTable::create(STATE, size_t size) {
    MethodTable *tbl;

    tbl = state->new_object<MethodTable>(G(methtbl));
    tbl->setup(state, size);

    return tbl;
  }
开发者ID:MarkusQ,项目名称:rubinius,代码行数:8,代码来源:methodtable.cpp

示例9: hookup_prim

  static void hookup_prim(STATE, Symbol* meth, Symbol* prim) {
    MethodTable* tbl = G(rubinius)->metaclass(state)->method_table();

    Executable* oc = Executable::allocate(state, Qnil);
    oc->primitive(state, prim);
    assert(oc->resolve_primitive(state));

    tbl->store(state, meth, oc, G(sym_public));
  }
开发者ID:dbalatero,项目名称:rubinius,代码行数:9,代码来源:class.cpp

示例10: CANNOTTHROWCOMPLUSEXCEPTION

MethodDesc *Binder::RawGetMethod(BinderMethodID id)
{
    CANNOTTHROWCOMPLUSEXCEPTION();
    _ASSERTE(m_pModule != NULL);
    _ASSERTE(id != METHOD__NIL);
    _ASSERTE(id <= m_cMethodRIDs);
    const MethodDescription *d = m_methodDescriptions + id - 1;
    MethodTable *pMT = RawGetClass(d->classID);
    _ASSERTE(pMT != NULL);
    MethodDesc *pMD = pMT->GetMethodDescForSlot(m_pMethodRIDs[id-1]-1);
    _ASSERTE(pMD != NULL);
    return pMD;
}
开发者ID:ArildF,项目名称:masters,代码行数:13,代码来源:binder.cpp

示例11: _ASSERTE

MethodTable *Binder::LookupClass(BinderClassID id, BOOL fLoad)
{
    _ASSERTE(m_pModule != NULL);
    _ASSERTE(id != CLASS__NIL);
    _ASSERTE(id <= m_cClassRIDs);

    MethodTable *pMT;

    const ClassDescription *d = m_classDescriptions + id - 1;

    NameHandle nh(d->name);

    if (!fLoad)
    {
        nh.SetTokenNotToLoad(tdAllTypes);
        pMT = m_pModule->GetClassLoader()->FindTypeHandle(&nh).AsMethodTable();
        if (pMT == NULL)
            return NULL;
    }
    else
    {
        THROWSCOMPLUSEXCEPTION();

        BEGIN_ENSURE_COOPERATIVE_GC();
        OBJECTREF pThrowable = NULL;
        GCPROTECT_BEGIN(pThrowable);

        pMT = m_pModule->GetClassLoader()->FindTypeHandle(&nh, &pThrowable).AsMethodTable();
        if (pMT == NULL)
        {
            _ASSERTE(!"EE expects class to exist");
            COMPlusThrow(pThrowable);
        }
        GCPROTECT_END();
        END_ENSURE_COOPERATIVE_GC();
    }

    _ASSERTE(pMT->GetModule() == m_pModule);

    mdTypeDef td = pMT->GetClass()->GetCl();

    _ASSERTE(!IsNilToken(td));

    _ASSERTE(RidFromToken(td) <= USHRT_MAX);
    m_pClassRIDs[id-1] = (USHORT) RidFromToken(td);

    m_pModule->StoreTypeDef(td, pMT);

    return pMT;
}
开发者ID:ArildF,项目名称:masters,代码行数:50,代码来源:binder.cpp

示例12: getDistributionMethods

MethodTable Dist_sampledSpeciationBirthDeathProcess::getDistributionMethods( void ) const
{
    
    MethodTable methods = TypedDistribution<TimeTree>::getDistributionMethods();
    
    // member functions
    ArgumentRules* numEventsArgRules = new ArgumentRules();
    //    parentArgRules->push_back( new ArgumentRule( "node", Natural::getClassTypeSpec(), "The index of the node.", ArgumentRule::BY_CONSTANT_REFERENCE, ArgumentRule::ANY ) );
    methods.addFunction( new DistributionMemberFunction<Dist_sampledSpeciationBirthDeathProcess, ModelVector<Natural> >( "numberEvents", variable, numEventsArgRules   ) );
    methods.addFunction( new DistributionMemberFunction<Dist_sampledSpeciationBirthDeathProcess, ModelVector<ModelVector<RealPos> > >( "eventTimes", variable, numEventsArgRules   ) );

    
    return methods;
}
开发者ID:hscarter,项目名称:revbayes,代码行数:14,代码来源:Dist_sampledSpeciationBirthDeathProcess.cpp

示例13: GetVersionResilientTypeHashCode

int GetVersionResilientTypeHashCode(TypeHandle type)
{
    if (!type.IsTypeDesc())
    {
        MethodTable *pMT = type.AsMethodTable();

        _ASSERTE(!pMT->IsArray());
        _ASSERTE(!IsNilToken(pMT->GetCl()));

        LPCUTF8 szNamespace;
        LPCUTF8 szName;
        IfFailThrow(pMT->GetMDImport()->GetNameOfTypeDef(pMT->GetCl(), &szName, &szNamespace));
        int hashcode = ComputeNameHashCode(szNamespace, szName);

        MethodTable *pMTEnclosing = pMT->LoadEnclosingMethodTable(CLASS_LOAD_UNRESTOREDTYPEKEY);
        if (pMTEnclosing != NULL)
        {
            hashcode = ComputeNestedTypeHashCode(GetVersionResilientTypeHashCode(TypeHandle(pMTEnclosing)), hashcode);
        }

        if (!pMT->IsGenericTypeDefinition() && pMT->HasInstantiation())
        {
            return ComputeGenericInstanceHashCode(hashcode,
                pMT->GetInstantiation().GetNumArgs(), pMT->GetInstantiation(), GetVersionResilientTypeHashCode);
        }
        else
        {
            return hashcode;
        }
    }
    else
    if (type.IsArray())
    {
        ArrayTypeDesc *pArray = type.AsArray();
        return ComputeArrayTypeHashCode(GetVersionResilientTypeHashCode(pArray->GetArrayElementTypeHandle()), pArray->GetRank());
    }
    else
    if (type.IsPointer())
    {
        return ComputePointerTypeHashCode(GetVersionResilientTypeHashCode(type.AsTypeDesc()->GetTypeParam()));
    }
    else
    if (type.IsByRef())
    {
        return ComputeByrefTypeHashCode(GetVersionResilientTypeHashCode(type.AsTypeDesc()->GetTypeParam()));
    }

    assert(false);
    return 0;
}
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:50,代码来源:versionresilienthashcode.cpp

示例14: MethodTable

MethodTable AbstractCharacterData::getCharacterDataMethods( void ) const
{
    
    MethodTable methods = MethodTable();
    
    ArgumentRules* namesArgRules                = new ArgumentRules();
    ArgumentRules* ntaxaArgRules                = new ArgumentRules();
    ArgumentRules* excludeTaxaArgRules          = new ArgumentRules();
    ArgumentRules* excludeTaxaArgRules2         = new ArgumentRules();
    ArgumentRules* includeTaxaArgRules          = new ArgumentRules();
    ArgumentRules* includeTaxaArgRules2         = new ArgumentRules();
    ArgumentRules* isSequenceMissingArgRules    = new ArgumentRules();
    ArgumentRules* percentageMissingArgRules    = new ArgumentRules();
    ArgumentRules* showdataArgRules             = new ArgumentRules();
    ArgumentRules* removeTaxaArgRules           = new ArgumentRules();
    ArgumentRules* removeTaxaArgRules2          = new ArgumentRules();
    ArgumentRules* setTaxonNameArgRules         = new ArgumentRules();
    
    excludeTaxaArgRules->push_back(         new ArgumentRule(""           , RlString::getClassTypeSpec()                , ArgumentRule::BY_VALUE) );
    excludeTaxaArgRules2->push_back(        new ArgumentRule(""           , ModelVector<RlString>::getClassTypeSpec()   , ArgumentRule::BY_VALUE) );
    includeTaxaArgRules->push_back(         new ArgumentRule(""           , RlString::getClassTypeSpec()                , ArgumentRule::BY_VALUE) );
    includeTaxaArgRules2->push_back(        new ArgumentRule(""           , ModelVector<RlString>::getClassTypeSpec()   , ArgumentRule::BY_VALUE) );
    isSequenceMissingArgRules->push_back(   new ArgumentRule(""           , RlString::getClassTypeSpec()                , ArgumentRule::BY_VALUE) );
    percentageMissingArgRules->push_back(   new ArgumentRule(""           , RlString::getClassTypeSpec()                , ArgumentRule::BY_VALUE) );
    removeTaxaArgRules->push_back(          new ArgumentRule(""           , RlString::getClassTypeSpec()                , ArgumentRule::BY_VALUE) );
    removeTaxaArgRules2->push_back(         new ArgumentRule(""           , ModelVector<RlString>::getClassTypeSpec()   , ArgumentRule::BY_VALUE) );
    setTaxonNameArgRules->push_back(        new ArgumentRule("current"    , RlString::getClassTypeSpec()                , ArgumentRule::BY_VALUE) );
    setTaxonNameArgRules->push_back(        new ArgumentRule("new"        , RlString::getClassTypeSpec()                , ArgumentRule::BY_VALUE) );
    

    methods.addFunction("excludeTaxa",          new MemberProcedure(RlUtils::Void,                 excludeTaxaArgRules          ) );
    methods.addFunction("excludeTaxa",          new MemberProcedure(RlUtils::Void,                 excludeTaxaArgRules2         ) );
    methods.addFunction("includeTaxa",          new MemberProcedure(RlUtils::Void,                 includeTaxaArgRules          ) );
    methods.addFunction("includeTaxa",          new MemberProcedure(RlUtils::Void,                 includeTaxaArgRules2         ) );
    methods.addFunction("isSequenceMissing",    new MemberProcedure(RlBoolean::getClassTypeSpec(), isSequenceMissingArgRules    ) );
    methods.addFunction("names",                new MemberProcedure(ModelVector<RlString>::getClassTypeSpec(), namesArgRules           ) );
    methods.addFunction("ntaxa",                new MemberProcedure(Natural::getClassTypeSpec(),   ntaxaArgRules                ) );
    methods.addFunction("percentageMissing",    new MemberProcedure(Probability::getClassTypeSpec(),            percentageMissingArgRules   ) );
    methods.addFunction("show",                 new MemberProcedure(RlUtils::Void,                 showdataArgRules             ) );
    methods.addFunction("removeTaxa",           new MemberProcedure(RlUtils::Void,                 removeTaxaArgRules           ) );
    methods.addFunction("removeTaxa",           new MemberProcedure(RlUtils::Void,                 removeTaxaArgRules2          ) );
    methods.addFunction("setTaxonName",         new MemberProcedure(RlUtils::Void,                 setTaxonNameArgRules         ) );
    
    // Add method for call "size" as a function
    ArgumentRules* sizeArgRules = new ArgumentRules();
    methods.addFunction("size",  new MemberProcedure( Natural::getClassTypeSpec(), sizeArgRules) );
    
    return methods;
}
开发者ID:wrightaprilm,项目名称:revbayes,代码行数:49,代码来源:RlAbstractCharacterData.cpp

示例15: attach_primitive

  void System::attach_primitive(STATE, Module* mod, bool meta, Symbol* name, Symbol* prim) {
    MethodTable* tbl;

    if(meta) {
      tbl = mod->singleton_class(state)->method_table();
    } else {
      tbl = mod->method_table();
    }

    Executable* oc = Executable::allocate(state, Qnil);
    oc->primitive(state, prim);
    oc->resolve_primitive(state);

    tbl->store(state, name, oc, G(sym_public));
  }
开发者ID:angelim,项目名称:rubinius,代码行数:15,代码来源:system.cpp


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