jitcraft/BytecodeCompiler.cpp
changeset 64 11c81eb30246
parent 63 dd57743d220e
child 65 7c942b5adebc
     1.1 --- a/jitcraft/BytecodeCompiler.cpp	Sun Jul 08 16:49:17 2012 -0700
     1.2 +++ b/jitcraft/BytecodeCompiler.cpp	Sun Jul 08 17:57:44 2012 -0700
     1.3 @@ -748,9 +748,21 @@
     1.4      if (!code)
     1.5          return NULL;
     1.6  
     1.7 -    Local<Function> fun(zone_, Function::New(zone_, module_, code, node->fun()->type(), node->pos()));
     1.8 +    Local<Type> type(zone_, node->fun()->type());
     1.9 +    Local<String> name(zone_, node->fun()->name());
    1.10 +    Local<Function> fun(zone_, Function::New(zone_, code, type, name, node->pos()));
    1.11      if (!fun)
    1.12          return NULL;
    1.13 +
    1.14 +    // If this function had a forward, export it as a named public.
    1.15 +    if (node->fun()->isPublic()) {
    1.16 +        assert(node->fun()->isPublic());
    1.17 +        ScopedRoot<Function> root(fun);
    1.18 +        if (!root)
    1.19 +            return NULL;
    1.20 +        if (!publics_.append(root))
    1.21 +            return NULL;
    1.22 +    }
    1.23      
    1.24      return fun;
    1.25  }
    1.26 @@ -772,5 +784,15 @@
    1.27          assert(module_->getFunction(i));
    1.28  #endif
    1.29  
    1.30 +    if (publics_.length()) {
    1.31 +        Local<Function> fun(zone_);
    1.32 +        Local<FixedArray> list(zone_, FixedArray::New(zone_, publics_.length(), Heap::Tenure_Old));
    1.33 +        if (!list)
    1.34 +            return NULL;
    1.35 +
    1.36 +        for (size_t i = 0; i < publics_.length(); i++)
    1.37 +            list->set(zone_, i, publics_[i]);
    1.38 +    }
    1.39 +
    1.40      return module_;
    1.41  }