本文整理汇总了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);
}
示例2: xl_enter_prefix
void xl_enter_prefix(Context *context, text name, native_fn fn, Tree *rtype,
TreeList ¶meters, 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);
}
}
示例3: xl_enter_form
void xl_enter_form(Context *context, text name, native_fn fn,
Tree *rtype, text form, TreeList ¶meters,
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);
}
示例4: xl_enter_postfix
void xl_enter_postfix(Context *context, text name, native_fn fn, Tree *rtype,
TreeList ¶meters, 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);
}
示例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);
}