Skip to content

Commit 5e0f68f

Browse files
committed
Defer smartness
Defer smartness and spec the minimal semantics of what is both safe, and non-leaky. Fixes #8.
1 parent b1f7da1 commit 5e0f68f

File tree

1 file changed

+63
-77
lines changed

1 file changed

+63
-77
lines changed

README.md

Lines changed: 63 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,12 @@ In the RegExpBuiltInExec abstract operation, a hook is added for updating the st
7070
1. **Let _LegacyRegExpConstructor_ be the value of _R_’s [[LegacyRegExpConstructor]] internal slot.**
7171
1. **If SameValue(_LegacyRegExpConstructor_, %RegExp%) is true, then**
7272
1. **Perform UpdateLegacyRegExpStaticProperties(%RegExp%, _S_, _lastIndex_, _e_, _capturedValues_).**
73+
1. (current step 25) Return _A_.
74+
75+
<!--
7376
1. **Else,**
7477
1. **Perform InvalidateLegacyRegExpStaticProperties(%RegExp%).**
75-
1. (current step 25) Return _A_.
78+
-->
7679

7780

7881
## UpdateLegacyRegExpStaticProperties ( _C_, _S_, _startIndex_, _endIndex_, _capturedValues_ )
@@ -95,164 +98,147 @@ The abstract operation UpdateLegacyRegExpStaticProperties updates the values of
9598
1. If _i__n_, set the value of _C_’s [[RegExpParen<i>i</i>]] internal slot to the <i>i</i>th element of _capturedValues_.
9699
1. Else, set the value of _C_’s [[RegExpParen<i>i</i>]] internal slot to the empty String.
97100

98-
101+
<!--
99102
## InvalidateLegacyRegExpStaticProperties ( _C_)
100103
101104
The abstract operation InvalidateLegacyRegExpStaticProperties marks the values of the static properties of %RegExp% as non-available.
102105
103-
_**Open issue.** It is probably more prudent to use the empty String instead of **empty**. See [Issue #6](https://github.com/claudepache/es-regexp-legacy-static-properties/issues/6). (In that case, the special treatment for the **empty** value in the algorithms of the next section will be removed as well.)_
104-
105106
106107
1. Assert: _C_ is an Object that has a [[RegExpInput]] internal slot.
107-
1. Set the value of _C_’s [[RegExpInput]] internal slot to **empty**.
108-
1. Set the value of _C_’s [[RegExpLastMatch]] internal slot to **empty**.
109-
1. Set the value of _C_’s [[RegExpLastParen]] internal slot to **empty**.
110-
1. Set the value of _C_’s [[RegExpLeftContext]] internal slot to **empty**.
111-
1. Set the value of _C_’s [[RegExpRightContext]] internal slot to **empty**.
112-
1. Set the value of _C_’s [[RegExpParen1]] internal slot to **empty**.
113-
1. Set the value of _C_’s [[RegExpParen2]] internal slot to **empty**.
114-
1. Set the value of _C_’s [[RegExpParen3]] internal slot to **empty**.
115-
1. Set the value of _C_’s [[RegExpParen4]] internal slot to **empty**.
116-
1. Set the value of _C_’s [[RegExpParen5]] internal slot to **empty**.
117-
1. Set the value of _C_’s [[RegExpParen6]] internal slot to **empty**.
118-
1. Set the value of _C_’s [[RegExpParen7]] internal slot to **empty**.
119-
1. Set the value of _C_’s [[RegExpParen8]] internal slot to **empty**.
120-
1. Set the value of _C_’s [[RegExpParen9]] internal slot to **empty**.
121-
108+
1. Set the value of _C_’s [[RegExpInput]] internal slot to the empty String.
109+
1. Set the value of _C_’s [[RegExpLastMatch]] internal slot to empty String.
110+
1. Set the value of _C_’s [[RegExpLastParen]] internal slot to empty String.
111+
1. Set the value of _C_’s [[RegExpLeftContext]] internal slot to empty String.
112+
1. Set the value of _C_’s [[RegExpRightContext]] internal slot to empty String.
113+
1. Set the value of _C_’s [[RegExpParen1]] internal slot to empty String.
114+
1. Set the value of _C_’s [[RegExpParen2]] internal slot to empty String.
115+
1. Set the value of _C_’s [[RegExpParen3]] internal slot to empty String.
116+
1. Set the value of _C_’s [[RegExpParen4]] internal slot to empty String.
117+
1. Set the value of _C_’s [[RegExpParen5]] internal slot to empty String.
118+
1. Set the value of _C_’s [[RegExpParen6]] internal slot to empty String.
119+
1. Set the value of _C_’s [[RegExpParen7]] internal slot to empty String.
120+
1. Set the value of _C_’s [[RegExpParen8]] internal slot to empty String.
121+
1. Set the value of _C_’s [[RegExpParen9]] internal slot to empty String.
122+
-->
122123

123124
## Additional properties of the RegExp constructor
124125

125-
All the below properties have the attributes { [[Enumerable]]: false, [[Configurable]]: true }. Moreover, for the properties whose setter is not explicitely defined, the [[Set]] attribute is set to undefined.
126+
All the below properties are accessor properties who have the attributes { [[Enumerable]]: false, [[Configurable]]: true }. Moreover, for the properties whose setter is not explicitely defined, the [[Set]] attribute is set to undefined.
127+
128+
The accessors check for their this value, so that the properties do not appear to be inherited by subclasses.
126129

127130

128131
### RegExp.input
129132
#### get RegExp.input
130133

131-
1. Let _v_ be the value of %RegExp%’s [[RegExpInput]] internal slot.
132-
1. If _v_ is **empty**, throw a **TypeError** exception.
133-
1. Return _v_.
134+
1. If SameValue(%RegExp%, this value) is false, return undefined.
135+
1. Return the value of %RegExp%’s [[RegExpInput]] internal slot.
134136

135137
#### set RegExp.input = _val_
136138

139+
1. If SameValue(%RegExp%, this value) is false, throw a TypeError Exception.
137140
1. Let _strVal_ be ? ToString(_val_).
138141
1. Set the value of %RegExp%’s [[RegExpInput]] internal slot to _strVal_.
139142

140143

141144
### RegExp.$_
142145
#### get RegExp.$_
143146

144-
1. Let _v_ be the value of %RegExp%’s [[RegExpInput]] internal slot.
145-
1. If _v_ is **empty**, throw a **TypeError** exception.
146-
1. Return _v_.
147+
1. If SameValue(%RegExp%, this value) is false, return undefined.
148+
1. Return the value of %RegExp%’s [[RegExpInput]] internal slot.
147149

148150
#### set RegExp.$_ = _val_
149151

152+
1. If SameValue(%RegExp%, this value) is false, throw a TypeError Exception.
150153
1. Let _strVal_ be ? ToString(_val_).
151154
1. Set the value of %RegExp%’s [[RegExpInput]] internal slot to _strVal_.
152155

153156

154157
### get RegExp.lastMatch
155158

156-
1. Let _v_ be the value of %RegExp%’s [[RegExpLastMatch]] internal slot.
157-
1. If _v_ is **empty**, throw a **TypeError** exception.
158-
1. Return _v_.
159+
1. If SameValue(%RegExp%, this value) is false, return undefined.
160+
1. Return the value of %RegExp%’s [[RegExpLastMatch]] internal slot.
159161

160162
### get RegExp.$&
161163

162-
1. Let _v_ be the value of %RegExp%’s [[RegExpLastMatch]] internal slot.
163-
1. If _v_ is **empty**, throw a **TypeError** exception.
164-
1. Return _v_.
164+
1. If SameValue(%RegExp%, this value) is false, return undefined.
165+
1. Return the value of %RegExp%’s [[RegExpLastMatch]] internal slot.
165166

166167
### get RegExp.lastParen
167168

168-
1. Let _v_ be the value of %RegExp%’s [[RegExpLastParen]] internal slot.
169-
1. If _v_ is **empty**, throw a **TypeError** exception.
170-
1. Return _v_.
169+
1. If SameValue(%RegExp%, this value) is false, return undefined.
170+
1. Return the value of %RegExp%’s [[RegExpLastParen]] internal slot.
171171

172172
### get RegExp.$+
173173

174-
1. Let _v_ be the value of %RegExp%’s [[RegExpLastParen]] internal slot.
175-
1. If _v_ is **empty**, throw a **TypeError** exception.
176-
1. Return _v_.
174+
1. If SameValue(%RegExp%, this value) is false, return undefined.
175+
1. Return the value of %RegExp%’s [[RegExpLastParen]] internal slot.
177176

178177
### get RegExp.leftContext
179178

180-
1. Let _v_ be the value of %RegExp%’s [[RegExpLeftContext]] internal slot.
181-
1. If _v_ is **empty**, throw a **TypeError** exception.
182-
1. Return _v_.
179+
1. If SameValue(%RegExp%, this value) is false, return undefined.
180+
1. Return the value of %RegExp%’s [[RegExpLeftContext]] internal slot.
183181

184182
### get RegExp.$`
185183

186-
1. Let _v_ be the value of %RegExp%’s [[RegExpLeftContext]] internal slot.
187-
1. If _v_ is **empty**, throw a **TypeError** exception.
188-
1. Return _v_.
184+
1. If SameValue(%RegExp%, this value) is false, return undefined.
185+
1. Return the value of %RegExp%’s [[RegExpLeftContext]] internal slot.
189186

190187
### get RegExp.rightContext
191188

192-
1. Let _v_ be the value of %RegExp%’s [[RegExpRightContext]] internal slot.
193-
1. If _v_ is **empty**, throw a **TypeError** exception.
194-
1. Return _v_.
189+
1. If SameValue(%RegExp%, this value) is false, return undefined.
190+
1. Return the value of %RegExp%’s [[RegExpRightContext]] internal slot.
195191

196192

197193
### get RegExp.$'
198194

199-
1. Let _v_ be the value of %RegExp%’s [[RegExpRightContext]] internal slot.
200-
1. If _v_ is **empty**, throw a **TypeError** exception.
201-
1. Return _v_.
195+
1. If SameValue(%RegExp%, this value) is false, return undefined.
196+
1. Return the value of %RegExp%’s [[RegExpRightContext]] internal slot.
202197

203198
### get RegExp.$1
204199

205-
1. Let _v_ be the value of %RegExp%’s [[RegExpParen1]] internal slot.
206-
1. If _v_ is **empty**, throw a **TypeError** exception.
207-
1. Return _v_.
200+
1. If SameValue(%RegExp%, this value) is false, return undefined.
201+
1. Return the value of %RegExp%’s [[RegExpParen1]] internal slot.
208202

209203
### get RegExp.$2
210204

211-
1. Let _v_ be the value of %RegExp%’s [[RegExpParen2]] internal slot.
212-
1. If _v_ is **empty**, throw a **TypeError** exception.
213-
1. Return _v_.
205+
1. If SameValue(%RegExp%, this value) is false, return undefined.
206+
1. Return the value of %RegExp%’s [[RegExpParen2]] internal slot.
214207

215208
### get RegExp.$3
216209

217-
1. Let _v_ be the value of %RegExp%’s [[RegExpParen3]] internal slot.
218-
1. If _v_ is **empty**, throw a **TypeError** exception.
219-
1. Return _v_.
210+
1. If SameValue(%RegExp%, this value) is false, return undefined.
211+
1. Return the value of %RegExp%’s [[RegExpParen3]] internal slot.
220212

221213
### get RegExp.$4
222214

223-
1. Let _v_ be the value of %RegExp%’s [[RegExpParen4]] internal slot.
224-
1. If _v_ is **empty**, throw a **TypeError** exception.
225-
1. Return _v_.
215+
1. If SameValue(%RegExp%, this value) is false, return undefined.
216+
1. Return the value of %RegExp%’s [[RegExpParen4]] internal slot.
226217

227218
### get RegExp.$5
228219

229-
1. Let _v_ be the value of %RegExp%’s [[RegExpParen5]] internal slot.
230-
1. If _v_ is **empty**, throw a **TypeError** exception.
231-
1. Return _v_.
220+
1. If SameValue(%RegExp%, this value) is false, return undefined.
221+
1. Return the value of %RegExp%’s [[RegExpParen5]] internal slot.
232222

233223
### get RegExp.$6
234224

235-
1. Let _v_ be the value of %RegExp%’s [[RegExpParen6]] internal slot.
236-
1. If _v_ is **empty**, throw a **TypeError** exception.
237-
1. Return _v_.
225+
1. If SameValue(%RegExp%, this value) is false, return undefined.
226+
1. Return the value of %RegExp%’s [[RegExpParen6]] internal slot.
238227

239228
### get RegExp.$7
240229

241-
1. Let _v_ be the value of %RegExp%’s [[RegExpParen7]] internal slot.
242-
1. If _v_ is **empty**, throw a **TypeError** exception.
243-
1. Return _v_.
230+
1. If SameValue(%RegExp%, this value) is false, return undefined.
231+
1. Return the value of %RegExp%’s [[RegExpParen7]] internal slot.
244232

245233
### get RegExp.$8
246234

247-
1. Let _v_ be the value of %RegExp%’s [[RegExpParen8]] internal slot.
248-
1. If _v_ is **empty**, throw a **TypeError** exception.
249-
1. Return _v_.
235+
1. If SameValue(%RegExp%, this value) is false, return undefined.
236+
1. Return the value of %RegExp%’s [[RegExpParen8]] internal slot.
250237

251238
### get RegExp.$9
252239

253-
1. Let _v_ be the value of %RegExp%’s [[RegExpParen9]] internal slot.
254-
1. If _v_ is **empty**, throw a **TypeError** exception.
255-
1. Return _v_.
240+
1. If SameValue(%RegExp%, this value) is false, return undefined.
241+
1. Return the value of %RegExp%’s [[RegExpParen9]] internal slot.
256242

257243

258244
## [RegExp.prototype.compile ( _pattern_, _flags_ )](https://tc39.github.io/ecma262/#sec-regexp.prototype.compile)

0 commit comments

Comments
 (0)