Comments (7)
@ljharb The conservative option is as you say: to treat the presence of directives as an annotation, like the proposed solution for storing scope info. That is, the extra bit will be validated. If the bit for strict mode is set and no "use strict" shows up in the AST, an error is thrown.
AIUI @littledan is proposing a slightly more radical approach of treating the bit as the source of truth. I am fine with this personally given that directives already feel extra-linguistic, though it does deviate from the guiding principle of "encode as little extra semantic info as possible, just properties of the AST".
from proposal-binary-ast.
This is a source of complexity in V8's parser as well (except we track the potential errors all the time, to avoid backtracking ever). Could the AST pre-parse "use strict" and instead set a bit on the function and not represent the string directly anymore?
from proposal-binary-ast.
Ah, I realize that the Babel AST already specifies a field
directives: [Directive]
where Directive
is basically a string literal. So, since we're following Babel for the moment, let's use it as is.
from proposal-binary-ast.
Forcing strict mode and foregoing this discussion for now would also be a great thing. Whatever smashes the with
statement.
from proposal-binary-ast.
@littledan Sounds like a good idea to me!
from proposal-binary-ast.
(the string should still show up in the AST tho, even if there's a precomputed bit, no?)
from proposal-binary-ast.
On a technical note, I'm not sure that a single bit is the most future-proof manner of handling this. After all, I seem to remember that at least V8 and SpiderMonkey have experimented with additional directives.
So I'd be tempted to add a property
directive: string | null
to both Function
and Program
(our AST root).
from proposal-binary-ast.
Related Issues (20)
- Subresource Integrity integration HOT 16
- .length property should be available for lazy function HOT 3
- Can we have `AssertedPositionalParameterName` interface which contains index? HOT 5
- Can we put more information into AssertedParameterScope ? HOT 2
- Why do some interfaces not inherit from Node? HOT 8
- (Optional) type information HOT 2
- Add comments to length field of functions. HOT 1
- Transfer repo to TC39 org HOT 5
- Add verification of property names vs identifiers
- What should be put into AssertedParameterScope for duplicate parameters? HOT 6
- Consider merging LiteralInfinityExpression into LiteralNumericExpression HOT 3
- Could the binary AST be...a bit more binary? HOT 1
- Consider splitting `LiteralNumericExpression` to `LiteralInt32Expression` + `LiteralFloatExpression`
- Could the AST be based on a reduced subset of productions? HOT 1
- Consider a compressed file format with pre-shared dictionary.
- Function.prototype.toString() HOT 12
- Modify IDL order if all JS engines benefit
- [question] I have a question that Binary AST file can be translated directly to bytecode or it should be translated to standard AST and then translated to bytecode in browser? HOT 2
- What is the current status of this proposal? HOT 12
- Solved by W3C EXI? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from proposal-binary-ast.