-
-
Notifications
You must be signed in to change notification settings - Fork 560
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* basic constructor, prototype and instance, * update some packages * remove null value from completion which violates NRT promises
- Loading branch information
Showing
51 changed files
with
648 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
namespace Jint.Native.Function | ||
namespace Jint.Native.Function; | ||
|
||
internal enum FunctionKind | ||
{ | ||
internal enum FunctionKind | ||
{ | ||
Normal, | ||
Async, | ||
Generator, | ||
AsyncGenerator | ||
} | ||
Normal, | ||
Async, | ||
Generator, | ||
AsyncGenerator | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Jint.Native.Function; | ||
using Jint.Native.Iterator; | ||
using Jint.Native.Object; | ||
using Jint.Runtime; | ||
using Jint.Runtime.Descriptors; | ||
|
||
namespace Jint.Native.Generator; | ||
|
||
/// <summary> | ||
/// https://tc39.es/ecma262/#sec-generatorfunction-constructor | ||
/// </summary> | ||
internal sealed class GeneratorFunctionConstructor : Constructor | ||
{ | ||
private static readonly JsString _functionName = new("GeneratorFunction"); | ||
|
||
internal GeneratorFunctionConstructor( | ||
Engine engine, | ||
Realm realm, | ||
FunctionPrototype prototype, | ||
IteratorPrototype iteratorPrototype) | ||
: base(engine, realm, _functionName) | ||
{ | ||
PrototypeObject = new GeneratorFunctionPrototype(engine, this, prototype, iteratorPrototype); | ||
_prototype = PrototypeObject; | ||
_prototypeDescriptor = new PropertyDescriptor(PrototypeObject, PropertyFlag.AllForbidden); | ||
_length = new PropertyDescriptor(JsNumber.PositiveOne, PropertyFlag.Configurable); | ||
} | ||
|
||
public GeneratorFunctionPrototype PrototypeObject { get; } | ||
|
||
protected internal override JsValue Call(JsValue thisObject, JsValue[] arguments) | ||
{ | ||
return Construct(arguments, thisObject); | ||
} | ||
|
||
public override ObjectInstance Construct(JsValue[] arguments, JsValue newTarget) | ||
{ | ||
var function = _realm.Intrinsics.Function.CreateDynamicFunction( | ||
this, | ||
newTarget, | ||
FunctionKind.Generator, | ||
arguments); | ||
|
||
return function; | ||
} | ||
} |
Oops, something went wrong.