• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ gc类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: compiler

  void Compiler::compileModule(VM& vm, ErrorReporter& reporter,
                                  gc<ModuleAst> ast, Module* module)
  {
    Compiler compiler(vm, reporter);

    for (int i = 0; i < ast->body()->expressions().count(); i++)
    {
      compiler.declareTopLevel(ast->body()->expressions()[i], module);
    }

    gc<Chunk> code = ExprCompiler(compiler).compileBody(module, ast->body());
    module->setBody(code);
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:13,代码来源:Compiler.cpp


示例2: dir

    gc<String> dir(gc<String> path)
    {
      // Find the last directory separator.
      int lastSeparator;
      for (lastSeparator = path->length() - 1; lastSeparator >= 0;
           lastSeparator--)
      {
        if ((*path)[lastSeparator] == separator()) break;
      }

      // If there are no directory separators, just return the original path.
      if (lastSeparator == -1) return path;

      return path->substring(0, lastSeparator);
    }
开发者ID:DawidvC,项目名称:magpie,代码行数:15,代码来源:Path.cpp


示例3: compileParamField

  void ExprCompiler::compileParamField(PatternCompiler& compiler,
                                         gc<Pattern> param, int slot)
  {
    VariablePattern* variable = param->asVariablePattern();
    if (variable != NULL)
    {
      // It's a variable, so compile its inner pattern. We don't worry about
      // the variable itself because the calling convention ensures its value
      // is already in the right slot.
      compiler.compile(variable->pattern(), slot);

      // If we closed over the parameter, then we don't want in a local slot,
      // we want it in the upvar, so create it and copy the value up.
      if (*variable->name() != "_" &&
          variable->resolved()->scope() == NAME_CLOSURE)
      {
        write(variable->pos(),
              OP_SET_UPVAR, variable->resolved()->index(), slot, 1);
      }
    }
    else
    {
      // Not a variable, so just compile it normally.
      compiler.compile(param, slot);
    }
  }
开发者ID:joshuawarner32,项目名称:magpie,代码行数:26,代码来源:ExprCompiler.cpp


示例4: sizeof

  gc<FunctionObject> FunctionObject::create(gc<Chunk> chunk)
  {
    // Allocate enough memory for the object and its upvars.
    void* mem = Memory::allocate(sizeof(FunctionObject) +
                                 sizeof(gc<Upvar>) * (chunk->numUpvars() - 1));

    // Construct it by calling global placement new.
    return ::new(mem) FunctionObject(chunk);
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:9,代码来源:Object.cpp


示例5: ASSERT

  gc<DynamicObject> DynamicObject::create(gc<ClassObject> classObj)
  {
    ASSERT(classObj->numFields() == 0, "Class cannot have fields.");

    // Allocate enough memory for the object.
    void* mem = Memory::allocate(sizeof(DynamicObject));

    // Construct it by calling global placement new.
    return ::new(mem) DynamicObject(classObj);
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:10,代码来源:Object.cpp


示例6: destructureParam

 void Resolver::destructureParam(gc<Pattern> pattern)
 {
   // No parameter so do nothing.
   if (pattern.isNull()) return;
   
   RecordPattern* record = pattern->asRecordPattern();
   if (record != NULL)
   {
     // Resolve each field.
     for (int i = 0; i < record->fields().count(); i++)
     {
       resolveParam(record->fields()[i].value);
     }
   }
   else
   {
     // If we got here, the pattern isn't a record, so its a single slot.
     resolveParam(pattern);
   }
 }
开发者ID:relrod,项目名称:magpie,代码行数:20,代码来源:Resolver.cpp


示例7: allocateSlotsForParam

 void Resolver::allocateSlotsForParam(gc<Pattern> pattern)
 {
   // No parameter so do nothing.
   if (pattern.isNull()) return;
   
   RecordPattern* record = pattern->asRecordPattern();
   if (record != NULL)
   {
     // Allocate each field.
     for (int i = 0; i < record->fields().count(); i++)
     {
       makeParamSlot(record->fields()[i].value);
     }
   }
   else
   {
     // If we got here, the pattern isn't a record, so it's a single slot.
     makeParamSlot(pattern);
   }
 }
开发者ID:relrod,项目名称:magpie,代码行数:20,代码来源:Resolver.cpp


示例8: makeParamSlot

 void Resolver::makeParamSlot(gc<Pattern> param)
 {
   VariablePattern* variable = param->asVariablePattern();
   if (variable != NULL && *variable->name() != "_")
   {
     // It's a variable, so create a named local for it and resolve the
     // variable.
     variable->setResolved(makeLocal(param->pos(), variable->name()));
     
     // Note that we do *not* resolve the variable's inner pattern here. We
     // do that after all param slots are resolved so that we can ensure the
     // param slots are contiguous.
   }
   else
   {
     // We don't have a variable for this parameter, but the argument
     // will still be on the stack, so make an unnamed slot for it.
     makeLocal(param->pos(), String::format("(%d)", unnamedSlotId_++));
   }
 }
开发者ID:relrod,项目名称:magpie,代码行数:20,代码来源:Resolver.cpp


示例9: open

  void FileObject::open(gc<Fiber> fiber, gc<String> path)
  {
    FSTask* task = new FSTask(fiber);

    // TODO(bob): Make this configurable.
    int flags = O_RDONLY;
    // TODO(bob): Make this configurable when creating a file.
    int mode = 0;
    uv_fs_open(task->loop(), task->request(), path->cString(), flags, mode,
               openFileCallback);
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:11,代码来源:IO.cpp


示例10: compileParam

  void ExprCompiler::compileParam(PatternCompiler& compiler,
                                    gc<Pattern> param, int& slot)
  {
    // No parameter so do nothing.
    if (param.isNull()) return;

    RecordPattern* record = param->asRecordPattern();
    if (record != NULL)
    {
      // Compile each field.
      for (int i = 0; i < record->fields().count(); i++)
      {
        compileParamField(compiler, record->fields()[i].value, slot++);
      }
    }
    else
    {
      // If we got here, the pattern isn't a record, so it's a single slot.
      compileParamField(compiler, param, slot++);
    }
  }
开发者ID:joshuawarner32,项目名称:magpie,代码行数:21,代码来源:ExprCompiler.cpp


示例11: compileArg

  int ExprCompiler::compileArg(gc<Expr> arg)
  {
    // No arg so do nothing.
    if (arg.isNull()) return 0;

    RecordExpr* record = arg->asRecordExpr();
    if (record != NULL)
    {
      // Compile each field.
      for (int i = 0; i < record->fields().count(); i++)
      {
        compile(record->fields()[i].value, makeTemp());
      }

      return record->fields().count();
    }

    // If we got here, the arg isn't a record, so its a single value.
    compile(arg, makeTemp());
    return 1;
  }
开发者ID:joshuawarner32,项目名称:magpie,代码行数:21,代码来源:ExprCompiler.cpp


示例12: send

  void ChannelObject::send(gc<Fiber> sender, gc<Object> value)
  {
    // TODO(bob): What if the channel is closed?

    // If we have a receiver, give it the value.
    if (receivers_.count() > 0)
    {
      gc<Fiber> receiver = receivers_.removeAt(0);
      receiver->storeReturn(value);
      receiver->ready();

      // Add the sender back to the scheduler too since it isn't blocked.
      sender->ready();
      return;
    }

    // Otherwise, stuff the value and suspend.
    sender->waitToSend(value);
    senders_.add(sender);
    return;
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:21,代码来源:Object.cpp


示例13: declareTopLevel

  void Compiler::declareTopLevel(gc<Expr> expr, Module* module)
  {
    DefExpr* def = expr->asDefExpr();
    if (def != NULL)
    {
      declareMultimethod(SignatureBuilder::build(*def));
      return;
    }

    DefClassExpr* defClass = expr->asDefClassExpr();
    if (defClass != NULL)
    {
      declareClass(*defClass, module);
      return;
    }

    VariableExpr* var = expr->asVariableExpr();
    if (var != NULL)
    {
      declareVariables(var->pattern(), module);
      return;
    }
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:23,代码来源:Compiler.cpp


示例14: declareVariable

  void Compiler::declareVariable(gc<SourcePos> pos, gc<String> name,
                                 Module* module)
  {
    // Make sure there isn't already a top-level variable with that name.
    int existing = module->findVariable(name);
    if (existing != -1)
    {
      reporter_.error(pos,
          "There is already a variable '%s' defined in this module.",
          name->cString());
    }

    module->addVariable(name, gc<Object>());
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:14,代码来源:Compiler.cpp


示例15: declareVariables

  void Compiler::declareVariables(gc<Pattern> pattern, Module* module)
  {
    RecordPattern* record = pattern->asRecordPattern();
    if (record != NULL)
    {
      for (int i = 0; i < record->fields().count(); i++)
      {
        declareVariables(record->fields()[i].value, module);
      }

      return;
    }

    VariablePattern* variable = pattern->asVariablePattern();
    if (variable != NULL)
    {
      declareVariable(variable->pos(), variable->name(), module);

      if (!variable->pattern().isNull())
      {
        declareVariables(variable->pattern(), module);
      }
    }
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:24,代码来源:Compiler.cpp


示例16: Task

  PrintTask::PrintTask(gc<Fiber> fiber, gc<Object> value, int numBuffers)
  : Task(fiber),
    value_(value)
  {
    request_.data = this;

    buffers_[0].base = const_cast<char*>(asString(value)->cString());
    buffers_[0].len = asString(value)->length();

    buffers_[1].base = const_cast<char*>("\n");
    buffers_[1].len = 1;

    uv_write(&request_,
             reinterpret_cast<uv_stream_t*>(fiber->scheduler().tty()),
             buffers_, 2, printCallback);
  }
开发者ID:,项目名称:,代码行数:16,代码来源:


示例17: resolveParam

 void Resolver::resolveParam(gc<Pattern> param)
 {
   VariablePattern* variable = param->asVariablePattern();
   if (variable != NULL)
   {
     // It's a variable, so resolve its inner pattern.
     if (!variable->pattern().isNull())
     {
       scope_->resolve(*variable->pattern());
     }
   }
   else
   {
     // Not a variable, so just resolve it normally.
     scope_->resolve(*param);
   }
 }
开发者ID:relrod,项目名称:magpie,代码行数:17,代码来源:Resolver.cpp


示例18: writeParam

  void SignatureBuilder::writeParam(gc<Pattern> pattern)
  {
    // If it's a record, destructure it into the signature.
    RecordPattern* record = pattern->asRecordPattern();
    if (record != NULL)
    {
      for (int i = 0; i < record->fields().count(); i++)
      {
        add(record->fields()[i].name);
        add(":");
      }

      return;
    }

    // Any other pattern is implicitly a single-field record.
    add("0:");
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:18,代码来源:Compiler.cpp


示例19: writeArg

  void SignatureBuilder::writeArg(gc<Expr> expr)
  {
    // If it's a record, destructure it into the signature.
    RecordExpr* record = expr->asRecordExpr();
    if (record != NULL)
    {
      for (int i = 0; i < record->fields().count(); i++)
      {
        add(record->fields()[i].name);
        add(":");
      }

      return;
    }

    // Right now, all other exprs mean "some arg goes here".
    add("0:");
  }
开发者ID:DawidvC,项目名称:magpie,代码行数:18,代码来源:Compiler.cpp


示例20: ResolvedName

  gc<ResolvedName> Resolver::makeLocal(gc<SourcePos> pos, gc<String> name)
  {
    // Make sure there isn't already a local variable with this name in the
    // current scope.
    for (int i = scope_->startSlot(); i < locals_.count(); i++)
    {
      if (locals_[i].name() == name)
      {
        compiler_.reporter().error(pos,
            "There is already a variable '%s' defined in this scope.",
            name->cString());
      }
    }

    gc<ResolvedName> resolved = new ResolvedName(locals_.count());
    locals_.add(Local(name, resolved));
    if (locals_.count() > maxLocals_) {
      maxLocals_ = locals_.count();
    }
            
    return resolved;
  }
开发者ID:relrod,项目名称:magpie,代码行数:22,代码来源:Resolver.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ gcRefPtr类代码示例发布时间:2022-05-31
下一篇:
C++ gamma_distribution类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap