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

support “new, delete, in, instanceof” keywords #124

Open
i7soft opened this issue Jan 19, 2021 · 1 comment
Open

support “new, delete, in, instanceof” keywords #124

i7soft opened this issue Jan 19, 2021 · 1 comment

Comments

@i7soft
Copy link

i7soft commented Jan 19, 2021

i add "in,instanceof" to binary_ops object,like:

binary_ops = {
			'in':0,'instanceof':0,
			'||': 1, '&&': 2, '|': 3,  '^': 4,  '&': 5,
			'==': 6, '!=': 6, '===': 6, '!==': 6,
			'<': 7,  '>': 7,  '<=': 7,  '>=': 7,
			'<<':8,  '>>': 8, '>>>': 8,
			'+': 9, '-': 9,
			'*': 10, '/': 10, '%': 10
		},

but how to support "new" and "delete" keywords?
like: new Date().valueOf(), first step should call "new Date",then call "valueOf"

{
    "type": "Compound",
    "body": [
        {
            "type": "Identifier",
            "name": "new"
        }, {
            "type": "CallExpression",
            "arguments": [],
            "callee": {
                "type": "MemberExpression",
                "computed": false,
                "object": {
                    "type": "CallExpression",
                    "arguments": [],
                    "callee": {
                        "type": "Identifier",
                        "name": "Date"
                    }
                },
                "property": {
                    "type": "Identifier",
                    "name": "valueOf"
                }
            }
        }
    ]
}


like:delete a.b

{
    "type": "Compound",
    "body": [
        {
            "type": "Identifier",
            "name": "delete"
        }, {
            "type": "MemberExpression",
            "computed": false,
            "object": {
                "type": "Identifier",
                "name": "a"
            },
            "property": {
                "type": "Identifier",
                "name": "b"
            }
        }
    ]
}
@LeaVerou
Copy link
Collaborator

You can add them as unary ops.

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