|
@@ -1,3 +1,6 @@
|
|
|
+using Jint.Runtime.Environments;
|
|
|
+using Environment = Jint.Runtime.Environments.Environment;
|
|
|
+
|
|
|
namespace Jint;
|
|
|
|
|
|
public partial class Engine
|
|
@@ -38,4 +41,28 @@ public class AdvancedOperations
|
|
|
{
|
|
|
_engine.RunAvailableContinuations();
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Creates a new declarative environment that has current lexical environment as outer scope.
|
|
|
+ /// </summary>
|
|
|
+ public Environment CreateDeclarativeEnvironment()
|
|
|
+ {
|
|
|
+ return JintEnvironment.NewDeclarativeEnvironment(_engine, _engine.ExecutionContext.LexicalEnvironment);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// Return the first constraint that matches the predicate.
|
|
|
+ /// </summary>
|
|
|
+ public T? FindConstraint<T>() where T : Constraint
|
|
|
+ {
|
|
|
+ foreach (var constraint in _engine._constraints)
|
|
|
+ {
|
|
|
+ if (constraint.GetType() == typeof(T))
|
|
|
+ {
|
|
|
+ return (T) constraint;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|