Skip to content

Conversation

@Yongqu
Copy link
Contributor

@Yongqu Yongqu commented Aug 8, 2016

Add support for module namespace. The basic syntax is
export * as myNS from 'submodule.js'
The namespace is a sealed object with all the exported properties from the currently
module. The properties are not changable. They are also "reference property" in that
it should look up the original property instead of caching the value of the property.

There are three set of properties in the namespace object:
. builtin Symbol properties, include Symbol.toStringTag & Symbol.iterator at this time.
. local exports. As the local exports are allocated in the specific slot array.
. nonlocal exports. We need to forward the call to other referencing module namespace object.

Similarly, the enumerator needs to take care of the different kinds of properties. However, the
iterator need to iterate through the property names in sorted order. We'll create the iterator
for a sorted name list. CreateListIterator operation (7.4.8) is implemented as well.

Add a set of unittests to cover the object behavior of namespace object.

Yongqu added 2 commits August 8, 2016 10:34
Add support for module namespace. The basic syntax is
export * as myNS from 'submodule.js'
The namespace is a sealed object with all the exported properties from the currently
module. The properties are not changable. They are also "reference property" in that
it should look up the original property instead of caching the value of the property.

There are three set of properties in the namespace object:
. builtin Symbol properties, include Symbol.toStringTag & Symbol.iterator at this time.
. local exports. As the local exports are allocated in the specific slot array.
. nonlocal exports. We need to forward the call to other referencing module namespace object.

Similarly, the enumerator needs to take care of the different kinds of properties. However, the
iterator need to iterate through the property names in sorted order. We'll create the iterator
for a sorted name list. CreateListIterator operation (7.4.8) is implemented as well.

Add a set of unittests to cover the object behavior of namespace object.
ENTRY(decodeURIComponent)
ENTRY2(default_, _u("default"))
ENTRY2(delete_, _u("delete")) // "delete" cannot be an identifier in C++ so using "delete_" instead
ENTRY2(star, _u("*"))
Copy link
Contributor

@boingoing boingoing Aug 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we indicate this is a symbol (change name to "_star" or similar)? It seems unlikely, but a built-in API might come along with the name of star (String.prototype.star maybe). #Resolved

@boingoing
Copy link
Contributor

boingoing commented Aug 10, 2016

Extra lines here if you're feeling pedantic. #Resolved


Refers to: lib/Runtime/Types/EdgeJavascriptTypeId.h:129 in 39d3005. [](commit_id = 39d3005, deletion_comment = False)

TypeIds_HostObject = 72,
TypeIds_ActivationObject = 73,
TypeIds_SpreadArgument = 74,
TypeIds_ModuleNamespace = 75,
Copy link
Contributor

@boingoing boingoing Aug 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeIds_ModuleNamespace [](start = 4, length = 23)

Is this object a "TrueJavascriptObjectType" ? #ByDesign

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it's a Var can be seen in the code.


In reply to: 74170764 [](ancestors = 74170764)

@boingoing
Copy link
Contributor

Cool stuff! 👍

@Yongqu
Copy link
Contributor Author

Yongqu commented Aug 10, 2016

:) fixed


In reply to: 238736817 [](ancestors = 238736817)


Refers to: lib/Runtime/Types/EdgeJavascriptTypeId.h:129 in 39d3005. [](commit_id = 39d3005, deletion_comment = False)

@Yongqu
Copy link
Contributor Author

Yongqu commented Aug 10, 2016

@dotnet-bot test Windows x86_test please

@chakrabot chakrabot merged commit a788132 into chakra-core:master Aug 11, 2016
chakrabot pushed a commit that referenced this pull request Aug 11, 2016
Merge pull request #1401 from Yongqu:modulens

 Add support for module namespace. The basic syntax is
    export * as myNS from 'submodule.js'
    The namespace is a sealed object with all the exported properties from the currently
    module. The properties are not changable. They are also "reference property" in that
    it should look up the original property instead of caching the value of the property.

    There are three set of properties in the namespace object:
    . builtin Symbol properties, include Symbol.toStringTag & Symbol.iterator at this time.
    . local exports. As the local exports are allocated in the specific slot array.
    . nonlocal exports. We need to forward the call to other referencing module namespace object.

    Similarly, the enumerator needs to take care of the different kinds of properties. However, the
    iterator need to iterate through the property names in sorted order. We'll create the iterator
    for a sorted name list. CreateListIterator operation (7.4.8) is implemented as well.

    Add a set of unittests to cover the object behavior of namespace object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants