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


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

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


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

示例1: xl_enter_block

void xl_enter_block(Context *context, text name, native_fn fn, Tree *rtype,
                    text open, text type, text close,
                    text doc)
// ----------------------------------------------------------------------------
//    Enter a block into the context (called from .tbl files)
// ----------------------------------------------------------------------------
{
    Tree *parms = xl_parameter("c", type);
    Block *from = new Block(parms, open, close);
    Name *to = new Name(open + close);

    from = new Block(from, open, close); // Extra block removed by Define

    Rewrite *rw = context->Define(from, to);
    rw->native = (native_fn) 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);
}
开发者ID:c3d,项目名称:XL-programming-language,代码行数:26,代码来源:opcodes.cpp

示例2: 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

示例3: xl_enter_form

void xl_enter_form(Context *context, text name, native_fn fn,
                   Tree *rtype, text form, TreeList &parameters,
                   text doc)
// ----------------------------------------------------------------------------
//    Enter an arbitrary form in the symbol table
// ----------------------------------------------------------------------------
{
    Tree *from = xl_parse_text(form);
    Name *to = new Name(name);

    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);

    ulong sz = parameters.size();
    if (sz != rw2->parameters.size())
    {
        std::cerr << "WARNING: Internal error on parameter count for "
                  << name << "\n"
                  << "         " << form << "\n";
        ulong sz2 = rw2->parameters.size();
        for (ulong i = 0; i < sz || i < sz2; i++)
        {
            std::cerr << "  #" << i << ": ";
            if (i < sz)
                std::cerr << "spec(" << parameters[i] << ") ";
            if (i < sz2)
                std::cerr << "form(" << rw2->parameters[i] << ") ";
            std::cerr << "\n";
        }
    }

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

示例4: xl_enter_postfix

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

    Rewrite *rw = context->Define(from, to);
    rw->native = (native_fn) 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);
}
开发者ID:c3d,项目名称:XL-programming-language,代码行数:23,代码来源:opcodes.cpp

示例5: xl_enter_infix

void xl_enter_infix(Context *context, text name, native_fn fn, Tree *rtype,
                    text t1, text symbol, text t2, text doc)
// ----------------------------------------------------------------------------
//   Enter an infix into the context (called from .tbl files)
// ----------------------------------------------------------------------------
{
    Tree *ldecl = xl_parameter("l", t1);
    Tree *rdecl = xl_parameter("r", t2);
    Infix *from = new Infix(symbol, ldecl, rdecl);
    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);
}
开发者ID:c3d,项目名称:XL-programming-language,代码行数:24,代码来源:opcodes.cpp


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