Skip to content

Commit

Permalink
feat(ecmascript): Implement Annex-B string prototype methods
Browse files Browse the repository at this point in the history
I also added some feature flags for including parts of or the whole of annex-b. Made them on-by-default, but might make more sense for them to be off?
  • Loading branch information
eliassjogreen committed Jan 21, 2025
1 parent e0a7bd3 commit 61ce8a8
Show file tree
Hide file tree
Showing 3 changed files with 488 additions and 6 deletions.
15 changes: 14 additions & 1 deletion nova_vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ default = [
"shared-array-buffer",
"weak-refs",
"atomics",
"regexp"
"regexp",
"annex-b"
]
array-buffer = []
atomics = ["array-buffer", "shared-array-buffer"]
Expand All @@ -52,6 +53,18 @@ regexp = []
shared-array-buffer = []
weak-refs = []
typescript = []
# Enables features defined by [Annex B](https://tc39.es/ecma262/#sec-additional-ecmascript-features-for-web-browsers)
annex-b = ["annex-b-string", "annex-b-global", "annex-b-date", "annex-b-regexp"]
# Adds the additional properties to the global object as defined by Annex B section [B.2.1](https://tc39.es/ecma262/#sec-additional-properties-of-the-global-object)
annex-b-global = []
# Adds the additional properties to the string prototype as defined by Annex B section [B.2.2](https://tc39.es/ecma262/#sec-additional-properties-of-the-string.prototype-object)
annex-b-string = []
# Adds the additional properties to the date prototype as defined by Annex B section [B.2.3](https://tc39.es/ecma262/#sec-additional-properties-of-the-date.prototype-object)
annex-b-date = ["date"]
# Adds the additional properties and syntax to regular expressions as defined by Annex B section:
# - [B.1.2](https://tc39.es/ecma262/#sec-regular-expressions-patterns)
# - [B.2.4](https://tc39.es/ecma262/#sec-additional-properties-of-the-regexp.prototype-object)
annex-b-regexp = ["regexp"]

[build-dependencies]
small_string = { path = "../small_string" }
17 changes: 16 additions & 1 deletion nova_vm/src/builtin_strings
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ AggregateError
all
allSettled
and
anchor
anonymous
any
apply
Expand All @@ -52,11 +53,14 @@ atan
atan2
atanh
Atomics
big
bigint
BigInt
BigInt64Array
BigUint64Array
bind
blink
bold
boolean
Boolean
bound
Expand Down Expand Up @@ -125,12 +129,15 @@ find
findIndex
findLast
findLastIndex
fixed
flags
flat
flatMap
Float32Array
Float64Array
floor
fontcolor
fontsize
for
forEach
freeze
Expand Down Expand Up @@ -232,11 +239,13 @@ isSafeInteger
isSealed
isView
isWellFormed
italics
iterator
join
JSON
keyFor
keys
link
lastIndex
lastIndexOf
length
Expand Down Expand Up @@ -356,6 +365,7 @@ sin
sinh
size
slice
small
some
sort
source
Expand All @@ -368,13 +378,16 @@ SQRT2
startsWith
sticky
store
strike
string
String
stringify
String Iterator
stringify
sub
subarray
substr
substring
sup
symbol
Symbol
Symbol.asyncIterator
Expand Down Expand Up @@ -423,6 +436,8 @@ transfer
transferToFixedLength
trim
trimEnd
trimLeft
trimRight
trimStart
true
trunc
Expand Down
Loading

0 comments on commit 61ce8a8

Please sign in to comment.