@@ -485,10 +485,10 @@ class ContextifyScript : public BaseObject {
485
485
486
486
TryCatch try_catch (env->isolate ());
487
487
Local<String> code = args[0 ]->ToString (env->isolate ());
488
- Local<String> filename = GetFilenameArg (args, 1 );
488
+ Local<String> filename = GetFilenameArg (env, args, 1 );
489
489
Local<Integer> lineOffset = GetLineOffsetArg (args, 1 );
490
490
Local<Integer> columnOffset = GetColumnOffsetArg (args, 1 );
491
- bool display_errors = GetDisplayErrorsArg (args, 1 );
491
+ bool display_errors = GetDisplayErrorsArg (env, args, 1 );
492
492
MaybeLocal<Uint8Array> cached_data_buf = GetCachedData (env, args, 1 );
493
493
bool produce_cached_data = GetProduceCachedData (env, args, 1 );
494
494
if (try_catch.HasCaught ()) {
@@ -559,18 +559,19 @@ class ContextifyScript : public BaseObject {
559
559
560
560
// args: [options]
561
561
static void RunInThisContext (const FunctionCallbackInfo<Value>& args) {
562
+ Environment* env = Environment::GetCurrent (args);
563
+
562
564
// Assemble arguments
563
565
TryCatch try_catch (args.GetIsolate ());
564
- uint64_t timeout = GetTimeoutArg (args, 0 );
565
- bool display_errors = GetDisplayErrorsArg (args, 0 );
566
- bool break_on_sigint = GetBreakOnSigintArg (args, 0 );
566
+ uint64_t timeout = GetTimeoutArg (env, args, 0 );
567
+ bool display_errors = GetDisplayErrorsArg (env, args, 0 );
568
+ bool break_on_sigint = GetBreakOnSigintArg (env, args, 0 );
567
569
if (try_catch.HasCaught ()) {
568
570
try_catch.ReThrow ();
569
571
return ;
570
572
}
571
573
572
574
// Do the eval within this context
573
- Environment* env = Environment::GetCurrent (args);
574
575
EvalMachine (env, timeout, display_errors, break_on_sigint, args,
575
576
&try_catch);
576
577
}
@@ -592,9 +593,9 @@ class ContextifyScript : public BaseObject {
592
593
Local<Object> sandbox = args[0 ].As <Object>();
593
594
{
594
595
TryCatch try_catch (env->isolate ());
595
- timeout = GetTimeoutArg (args, 1 );
596
- display_errors = GetDisplayErrorsArg (args, 1 );
597
- break_on_sigint = GetBreakOnSigintArg (args, 1 );
596
+ timeout = GetTimeoutArg (env, args, 1 );
597
+ display_errors = GetDisplayErrorsArg (env, args, 1 );
598
+ break_on_sigint = GetBreakOnSigintArg (env, args, 1 );
598
599
if (try_catch.HasCaught ()) {
599
600
try_catch.ReThrow ();
600
601
return ;
@@ -668,14 +669,14 @@ class ContextifyScript : public BaseObject {
668
669
True (env->isolate ()));
669
670
}
670
671
671
- static bool GetBreakOnSigintArg (const FunctionCallbackInfo<Value>& args,
672
+ static bool GetBreakOnSigintArg (Environment* env,
673
+ const FunctionCallbackInfo<Value>& args,
672
674
const int i) {
673
675
if (args[i]->IsUndefined () || args[i]->IsString ()) {
674
676
return false ;
675
677
}
676
678
if (!args[i]->IsObject ()) {
677
- Environment::ThrowTypeError (args.GetIsolate (),
678
- " options must be an object" );
679
+ env->ThrowTypeError (" options must be an object" );
679
680
return false ;
680
681
}
681
682
@@ -685,14 +686,14 @@ class ContextifyScript : public BaseObject {
685
686
return value->IsTrue ();
686
687
}
687
688
688
- static int64_t GetTimeoutArg (const FunctionCallbackInfo<Value>& args,
689
+ static int64_t GetTimeoutArg (Environment* env,
690
+ const FunctionCallbackInfo<Value>& args,
689
691
const int i) {
690
692
if (args[i]->IsUndefined () || args[i]->IsString ()) {
691
693
return -1 ;
692
694
}
693
695
if (!args[i]->IsObject ()) {
694
- Environment::ThrowTypeError (args.GetIsolate (),
695
- " options must be an object" );
696
+ env->ThrowTypeError (" options must be an object" );
696
697
return -1 ;
697
698
}
698
699
@@ -704,22 +705,21 @@ class ContextifyScript : public BaseObject {
704
705
int64_t timeout = value->IntegerValue ();
705
706
706
707
if (timeout <= 0 ) {
707
- Environment::ThrowRangeError (args.GetIsolate (),
708
- " timeout must be a positive number" );
708
+ env->ThrowRangeError (" timeout must be a positive number" );
709
709
return -1 ;
710
710
}
711
711
return timeout;
712
712
}
713
713
714
714
715
- static bool GetDisplayErrorsArg (const FunctionCallbackInfo<Value>& args,
715
+ static bool GetDisplayErrorsArg (Environment* env,
716
+ const FunctionCallbackInfo<Value>& args,
716
717
const int i) {
717
718
if (args[i]->IsUndefined () || args[i]->IsString ()) {
718
719
return true ;
719
720
}
720
721
if (!args[i]->IsObject ()) {
721
- Environment::ThrowTypeError (args.GetIsolate (),
722
- " options must be an object" );
722
+ env->ThrowTypeError (" options must be an object" );
723
723
return false ;
724
724
}
725
725
@@ -731,7 +731,8 @@ class ContextifyScript : public BaseObject {
731
731
}
732
732
733
733
734
- static Local<String> GetFilenameArg (const FunctionCallbackInfo<Value>& args,
734
+ static Local<String> GetFilenameArg (Environment* env,
735
+ const FunctionCallbackInfo<Value>& args,
735
736
const int i) {
736
737
Local<String> defaultFilename =
737
738
FIXED_ONE_BYTE_STRING (args.GetIsolate (), " evalmachine.<anonymous>" );
@@ -743,8 +744,7 @@ class ContextifyScript : public BaseObject {
743
744
return args[i].As <String>();
744
745
}
745
746
if (!args[i]->IsObject ()) {
746
- Environment::ThrowTypeError (args.GetIsolate (),
747
- " options must be an object" );
747
+ env->ThrowTypeError (" options must be an object" );
748
748
return Local<String>();
749
749
}
750
750
@@ -770,9 +770,7 @@ class ContextifyScript : public BaseObject {
770
770
}
771
771
772
772
if (!value->IsUint8Array ()) {
773
- Environment::ThrowTypeError (
774
- args.GetIsolate (),
775
- " options.cachedData must be a Buffer instance" );
773
+ env->ThrowTypeError (" options.cachedData must be a Buffer instance" );
776
774
return MaybeLocal<Uint8Array>();
777
775
}
778
776
0 commit comments