Jurassic.Compiler.DynamicILGenerator.CastClass C# (CSharp) Method

CastClass() public method

Pops an object off the stack, checks that the object inherits from or implements the given type, and pushes the object onto the stack if the check was successful or throws an InvalidCastException if the check failed.
public CastClass ( Type type ) : void
type System.Type The type of the class the object inherits from or the interface the /// object implements.
return void
        public override void CastClass(Type type)
        {
            if (type == null)
                throw new ArgumentNullException("type");

            //if (this.EnableDiagnostics == true && ScriptEngine.LowPrivilegeEnvironment == false)
            //{
            //    // Provides more information if a cast fails.
            //    var endOfCheckLabel = this.CreateLabel();
            //    this.Duplicate();
            //    this.IsInstance(type);
            //    this.BranchIfNotNull(endOfCheckLabel);
            //    this.LoadToken(type);
            //    this.Call(ReflectionHelpers.Type_GetTypeFromHandle);
            //    this.LoadString(Environment.StackTrace);
            //    this.Call(typeof(DynamicILGenerator).GetMethod("OnFailedCast", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic));
            //    this.Throw();
            //    this.DefineLabelPosition(endOfCheckLabel);
            //}

            int token = this.GetToken(type);
            Emit1ByteOpCodeInt32(0x74, 1, 1, token);
            PopStackOperands(VESType.Object);
            PushStackOperand(VESType.Object);
        }
DynamicILGenerator