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

Add V8IntrinsicIdentifier printing #2

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/babel-generator/src/generators/expressions.js
Expand Up @@ -264,3 +264,8 @@ export function PrivateName(node: Object) {
this.token("#");
this.print(node.id, node);
}

export function V8IntrinsicIdentifier(node: Object) {
this.token("%");
this.word(node.name);
}
@@ -0,0 +1 @@
%DebugPrint(foo);
@@ -0,0 +1,3 @@
{
"plugins": ["v8intrinsic"]
}
@@ -0,0 +1 @@
%DebugPrint(foo);
3 changes: 2 additions & 1 deletion packages/babel-types/scripts/utils/formatBuilderName.js
Expand Up @@ -5,5 +5,6 @@ const toLowerCase = Function.call.bind("".toLowerCase);
module.exports = function formatBuilderName(type) {
// FunctionExpression -> functionExpression
// JSXIdentifier -> jsxIdentifier
return type.replace(/^([A-Z](?=[a-z])|[A-Z]+(?=[A-Z]))/, toLowerCase);
// V8IntrinsicIdentifier -> v8IntrinsicIdentifier
return type.replace(/^([A-Z](?=[a-z0-9])|[A-Z]+(?=[A-Z]))/, toLowerCase);
};
6 changes: 6 additions & 0 deletions packages/babel-types/src/asserts/generated/index.js
Expand Up @@ -663,6 +663,12 @@ export function assertNoop(node: Object, opts?: Object = {}): void {
export function assertPlaceholder(node: Object, opts?: Object = {}): void {
assert("Placeholder", node, opts);
}
export function assertV8IntrinsicIdentifier(
node: Object,
opts?: Object = {},
): void {
assert("V8IntrinsicIdentifier", node, opts);
}
export function assertArgumentPlaceholder(
node: Object,
opts?: Object = {},
Expand Down
4 changes: 4 additions & 0 deletions packages/babel-types/src/builders/generated/index.js
Expand Up @@ -600,6 +600,10 @@ export function Placeholder(...args: Array<any>): Object {
return builder("Placeholder", ...args);
}
export { Placeholder as placeholder };
export function V8IntrinsicIdentifier(...args: Array<any>): Object {
return builder("V8IntrinsicIdentifier", ...args);
}
export { V8IntrinsicIdentifier as v8IntrinsicIdentifier };
export function ArgumentPlaceholder(...args: Array<any>): Object {
return builder("ArgumentPlaceholder", ...args);
}
Expand Down
13 changes: 12 additions & 1 deletion packages/babel-types/src/definitions/misc.js
@@ -1,5 +1,9 @@
// @flow
import defineType, { assertNodeType, assertOneOf } from "./utils";
import defineType, {
assertNodeType,
assertOneOf,
assertValueType,
} from "./utils";
import { PLACEHOLDERS } from "./placeholders";

defineType("Noop", {
Expand All @@ -19,3 +23,10 @@ defineType("Placeholder", {
},
},
});

defineType("V8IntrinsicIdentifier", {
builder: ["name"],
fields: {
name: assertValueType("string"),
},
});
14 changes: 14 additions & 0 deletions packages/babel-types/src/validators/generated/index.js
Expand Up @@ -2107,6 +2107,20 @@ export function isPlaceholder(node: ?Object, opts?: Object): boolean {

return false;
}
export function isV8IntrinsicIdentifier(node: ?Object, opts?: Object): boolean {
if (!node) return false;

const nodeType = node.type;
if (nodeType === "V8IntrinsicIdentifier") {
if (typeof opts === "undefined") {
return true;
} else {
return shallowEqual(node, opts);
}
}

return false;
}
export function isArgumentPlaceholder(node: ?Object, opts?: Object): boolean {
if (!node) return false;

Expand Down