/* classRecogniser( key )( object ) -> Bool */ Ref * sysClassRecogniser( Ref * pc, MachineClass *vm ) { if ( vm->count != 1 ) throw Ginger::Mishap( "Wrong number of arguments" ); Ref kk = vm->fastPeek(); if ( !IsObj( kk ) || *RefToPtr4( kk ) != sysClassKey ) throw Ginger::Mishap( "Key needed" ); CodeGen codegen = vm->codegen(); codegen->vmiFUNCTION( makeName( "is", RefToPtr4( kk )[ CLASS_OFFSET_TITLE ] ), 1, 1 ); codegen->vmiSYS_CALL_ARG( sysargRecognise, kk ); codegen->vmiSYS_RETURN(); vm->fastPeek() = codegen->vmiENDFUNCTION(); return pc; }
/* classExploder( key )( instance ) -> ( arg1, ..., argN ) */ Ref * sysClassExploder( Ref * pc, MachineClass * vm ) { if ( vm->count != 1 ) throw Ginger::Mishap( "Wrong number of arguments" ); Ref key = vm->fastPeek(); if ( !IsObj( key ) ) throw Ginger::Mishap( "Class of object needed" ); Ref * key_K = RefToPtr4( key ); if ( *key_K != sysClassKey ) throw Ginger::Mishap( "Class of object needed" ); const long N = SmallToLong( key_K[ CLASS_OFFSET_NFIELDS ] ); CodeGen codegen = vm->codegen(); codegen->vmiFUNCTION( makeName( "dest", key_K[ CLASS_OFFSET_TITLE ] ), 1, N ); codegen->vmiSYS_CALL_ARG( sysargExplode, key ); codegen->vmiSYS_RETURN(); vm->fastPeek() = codegen->vmiENDFUNCTION(); return pc; }