diff options
author | 2023-09-18 20:33:58 -0400 | |
---|---|---|
committer | 2023-09-18 17:33:58 -0700 | |
commit | eb1dc7eede31b12726ae320263850fefaaf490f3 (patch) | |
tree | 68a1a29b2505dc01fc65d94b0eecd40a06186778 /src/js/_codegen/build-functions.ts | |
parent | 79dd196edd820db5212da1a524fd5f888b38a3aa (diff) | |
download | bun-eb1dc7eede31b12726ae320263850fefaaf490f3.tar.gz bun-eb1dc7eede31b12726ae320263850fefaaf490f3.tar.zst bun-eb1dc7eede31b12726ae320263850fefaaf490f3.zip |
fix(runtime/node): Allow `new Buffer.alloc()` + Upgrade WebKit (#5699)
* make bufferconstructor a static hash table
* chore: Upgrade WebKit to 4d995edbc44062b251be638818edcd88d7d14dd7
* make it constructable now
* fix comment
* yippee
* update CI workflows
Diffstat (limited to 'src/js/_codegen/build-functions.ts')
-rw-r--r-- | src/js/_codegen/build-functions.ts | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/js/_codegen/build-functions.ts b/src/js/_codegen/build-functions.ts index d4d6f9235..6e4114624 100644 --- a/src/js/_codegen/build-functions.ts +++ b/src/js/_codegen/build-functions.ts @@ -28,9 +28,9 @@ interface BundledBuiltin { name: string; directives: Record<string, any>; isGetter: boolean; - isConstructor: boolean; + constructAbility: string; + constructKind: string; isLinkTimeConstant: boolean; - isNakedConstructor: boolean; intrinsic: string; overriddenName: string; source: string; @@ -97,12 +97,13 @@ async function processFileSplit(filename: string): Promise<{ functions: BundledB throw new SyntaxError("Could not parse directive value " + directive[2] + " (must be JSON parsable)"); } if (name === "constructor") { - throw new SyntaxError("$constructor not implemented"); + directives.ConstructAbility = "CanConstruct"; + } else if (name === "nakedConstructor") { + directives.ConstructAbility = "CanConstruct"; + directives.ConstructKind = "Naked"; + } else { + directives[name] = value; } - if (name === "nakedConstructor") { - throw new SyntaxError("$nakedConstructor not implemented"); - } - directives[name] = value; contents = contents.slice(directive[0].length); } else if (match[1] === "export function" || match[1] === "export async function") { const declaration = contents.match( @@ -192,9 +193,9 @@ $$capture_start$$(${fn.async ? "async " : ""}${ params: fn.params, visibility: fn.directives.visibility ?? (fn.directives.linkTimeConstant ? "Private" : "Public"), isGetter: !!fn.directives.getter, - isConstructor: !!fn.directives.constructor, + constructAbility: fn.directives.ConstructAbility ?? "CannotConstruct", + constructKind: fn.directives.ConstructKind ?? "None", isLinkTimeConstant: !!fn.directives.linkTimeConstant, - isNakedConstructor: !!fn.directives.nakedConstructor, intrinsic: fn.directives.intrinsic ?? "NoIntrinsic", overriddenName: fn.directives.getter ? `"get ${fn.name}"_s` @@ -256,8 +257,8 @@ for (const { basename, functions } of files) { for (const fn of functions) { const name = `${lowerBasename}${cap(fn.name)}Code`; bundledCPP += `// ${fn.name} -const JSC::ConstructAbility s_${name}ConstructAbility = JSC::ConstructAbility::CannotConstruct; -const JSC::ConstructorKind s_${name}ConstructorKind = JSC::ConstructorKind::None; +const JSC::ConstructAbility s_${name}ConstructAbility = JSC::ConstructAbility::${fn.constructAbility}; +const JSC::ConstructorKind s_${name}ConstructorKind = JSC::ConstructorKind::${fn.constructKind}; const JSC::ImplementationVisibility s_${name}ImplementationVisibility = JSC::ImplementationVisibility::${fn.visibility}; const int s_${name}Length = ${fn.source.length}; static const JSC::Intrinsic s_${name}Intrinsic = JSC::NoIntrinsic; |