Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we put more information into AssertedParameterScope ? #51

Closed
arai-a opened this issue Jul 13, 2018 · 2 comments
Closed

Can we put more information into AssertedParameterScope ? #51

arai-a opened this issue Jul 13, 2018 · 2 comments

Comments

@arai-a
Copy link

arai-a commented Jul 13, 2018

Another extension for https://github.com/binast/ecmascript-binary-ast/issues/50

The requirement on the implementation is following:
https://bugzilla.mozilla.org/show_bug.cgi?id=1475458

To satisfy it without changing the implementation (this is just for reference. I'm also thinking about changing implementation side), the following structure is necessary:

enum ParameterKind {
    "simple",
    "default",
    "destructuring",
    "destructuring default",
    "rest",
    "destructuring rest"
};

interface AssertedParameterName {
  attribute unsigned short index;
  attribute ParameterKind kind;
  attribute IdentifierName name;
  attribute boolean isCaptured;
};

interface AssertedParameterScope {
  attribute FrozenArray<AssertedParameterName> paramNames;
  attribute boolean hasDirectEval;
};

index is where the binding is defined in parameters list.

for example, function f(a, b=10, {c}, [d, e] = [], f, ...g) {} has the following scope data:

AssertedParameterScope {
  paramNames: [
    AssertedParameterName {
      index: 0, kind: "simple", name: "a", isCaptured: false
    },
    AssertedParameterName {
      index: 1, kind: "default", name: "b", isCaptured: false
    },
    AssertedParameterName {
      index: 2, kind: "destructuring", name: "c", isCaptured: false
    },
    AssertedParameterName {
      index: 3, kind: "destructuring default", name: "d", isCaptured: false
    },
    AssertedParameterName {
      index: 3, kind: "destructuring default", name: "e", isCaptured: false
    },
    AssertedParameterName {
      index: 4, kind: "simple", name: "f", isCaptured: false
    },
    AssertedParameterName {
      index: 5, kind: "rest", name: "g", isCaptured: false
    },
  ],
  hasDirectEval: false
}

Also, we need bodyScope before param.

@syg
Copy link
Collaborator

syg commented Jul 26, 2018

I like #50, but this doesn't feel right to standardize in the format.

@arai-a
Copy link
Author

arai-a commented Jul 27, 2018

okay, I'll think about more lightweight solution.

@arai-a arai-a closed this as completed Jul 27, 2018
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

No branches or pull requests

2 participants