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


C++ Symbols::EnterName方法代码示例

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


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

示例1: xl_enter_prefix

void xl_enter_prefix(Context *context, text name, native_fn fn, Tree *rtype,
                     TreeList &parameters, text symbol, text doc)
// ----------------------------------------------------------------------------
//   Enter a prefix into the context (called from .tbl files)
// ----------------------------------------------------------------------------
{
    if (parameters.size())
    {
        Tree *parmtree = xl_parameters_tree(parameters);
        Prefix *from = new Prefix(new Name(symbol), parmtree);
        Name *to = new Name(symbol);

        Rewrite *rw = context->Define(from, to);
        rw->native = fn;
        rw->type = rtype;

        Symbols *s = MAIN->globals;
        Rewrite *rw2 = s->EnterRewrite(from, to);
        rw2->type = rtype;
        to->code = fn;
        to->SetSymbols(s);
        xl_enter_builtin(MAIN, name, to, rw2->parameters, fn);

        xl_set_documentation(from, doc);
    }
    else
    {
        Name *n  = new Name(symbol);
        n->SetInfo<PrefixDefinitionsInfo>(new PrefixDefinitionsInfo());
        Rewrite *rw = context->Define(n, n);
        rw->native = fn;
        rw->type = rtype;

        Symbols *s = MAIN->globals;
        Rewrite *rw2 = s->EnterName(symbol, n, Rewrite::GLOBAL);
        rw2->type = rtype;
        n->code = fn;
        n->SetSymbols(s);
        TreeList noparms;
        xl_enter_builtin(MAIN, name, n, noparms, fn);

        xl_set_documentation(n, doc);
    }
}
开发者ID:c3d,项目名称:XL-programming-language,代码行数:44,代码来源:opcodes.cpp

示例2: LoadFile


//.........这里部分代码省略.........
        if (options.doDiff)
        {
            files[file] = SourceFile (file, NULL, NULL, NULL);
            hadError = false;
        }
    }

    // Create new symbol table for the file, or clear it if we had one
    Context *ctx = MAIN->context;
    Context *savedCtx = ctx;
    Symbols *syms = MAIN->globals;
    Symbols *savedSyms = syms;
    if (sf.context)
    {
        updateContext = false;
        ctx = sf.context;
        syms = sf.symbols;
        ctx->Clear();
        syms->Clear();
    }
    else
    {
        ctx = new Context(ctx, NULL);
        syms = new Symbols(syms);
        syms->name = file;
    }
    MAIN->context = ctx;
    MAIN->globals = syms;
    syms->is_global = true;

    // Connect imports if any
    if (importContext)
        importContext->Import(ctx);
    if (importSymbols)
        importSymbols->Import(syms);

    // HACK - do not hide imported .xl
    if (file.find(".ddd") == file.npos &&
        file.find("tao.xl") == file.npos &&
        file.find("builtins.xl") == file.npos)
    {
        Name_p module_file = new Name("module_file"); // TODO: Position
        Name_p module_dir = new Name("module_dir");
        Text_p module_file_value = new Text(file);
        Text_p module_dir_value = new Text(ParentDir(file));
        ctx->Define(module_file, module_file_value);
        ctx->Define(module_dir, module_dir_value);
        syms->EnterName(module_file->value, module_file_value,Rewrite::LOCAL);
        syms->EnterName(module_dir->value, module_dir_value,Rewrite::LOCAL);
    }

    // Register the source file we had
    sf = SourceFile (file, tree, ctx, syms);
    if (tree)
    {
        // Set symbols and compile if required
        if (!options.parseOnly)
        {
            if (options.optimize_level == 1)
            {
                tree->SetSymbols(syms);
                if (!tree)
                    hadError = true;
                else
                    files[file].tree = tree;
                syms->ProcessDeclarations(tree);
            }

            // TODO: At -O3, do we need to do anything here?
        }
       
        // Graph of the input tree
        if (options.showGV)
        {
            SetNodeIdAction sni;
            BreadthFirstSearch<SetNodeIdAction> bfs(sni);
            tree->Do(bfs);
            GvOutput gvout(std::cout);
            tree->Do(gvout);
        }
    }

    if (options.showSource)
        std::cout << tree << "\n";
    if (options.verbose)
        debugp(tree);

    // Decide if we update symbols for next run
    if (!updateContext)
    {
        MAIN->context = savedCtx;
        MAIN->globals = savedSyms;
    }

    IFTRACE(symbols)
        std::cerr << "Loaded file " << file
                  << " with context " << MAIN->context << '\n';

    return hadError;
}
开发者ID:trustifier,项目名称:xlr,代码行数:101,代码来源:main.cpp


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