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


C++ StackFrame::addToFrame方法代码示例

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


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

示例1: IntermediateData


//.........这里部分代码省略.........
        delete *it; //say so long to our lovely data structure the AST
    }
    
    //Z_message("yes");
    
    //globals have been initialized, now we repeat for the functions
    for(vector<ASTFuncDecl *>::iterator it = funcs.begin(); it != funcs.end(); it++)
    {
        bool isarun = false;
        string scriptname;
        
        for(map<string,int>::iterator it2 = runsymbols.begin(); it2 != runsymbols.end(); it2++)
        {
            if(it2->second == symbols->getID(*it))
            {
                isarun=true;
                scriptname = it2->first;
                break;
            }
        }
        
        vector<Opcode *> funccode;
        //count the number of stack-allocated variables
        vector<int> stackvars;
        pair<vector<int> *, SymbolTable *> param = pair<vector<int> *, SymbolTable *>(&stackvars, symbols);
        CountStackSymbols temp;
        (*it)->execute(temp, &param);
        int offset = 0;
        StackFrame sf;
        
        //if this is a run, there is the this pointer
        if(isarun)
        {
            sf.addToFrame(thisptr[scriptname], offset);
            offset += 10000;
        }
        
        //the params are now the first elements of this list
        //so assign them depths in reverse order
        for(vector<int>::reverse_iterator it2 = stackvars.rbegin(); it2 != stackvars.rend(); it2++)
        {
            sf.addToFrame(*it2, offset);
            offset += 10000;
        }
        
        //start of the function
        Opcode *first = new OSetImmediate(new VarArgument(EXP1), new LiteralArgument(0));
        first->setLabel(lt.functionToLabel(symbols->getID(*it)));
        funccode.push_back(first);
        //push on the 0s
        int numtoallocate = (unsigned int)stackvars.size()-(unsigned int)symbols->getFuncParams(symbols->getID(*it)).size();
        
        for(int i = 0; i < numtoallocate; i++)
        {
            funccode.push_back(new OPushRegister(new VarArgument(EXP1)));
        }
        
        //push on the this, if a script
        if(isarun)
        {
            switch(scripttypes[scriptname])
            {
            case ScriptParser::TYPE_FFC:
                funccode.push_back(new OSetRegister(new VarArgument(EXP2), new VarArgument(REFFFC)));
                break;
                
开发者ID:SyrianBallaS,项目名称:ZeldaClassic,代码行数:66,代码来源:ScriptParser.cpp


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