src/som/interpreter/nodes/TypeCheckNode.java
public <E> E check(final E argument, final SType type) {
      if (VmSettings.COLLECT_TYPE_STATS) {
        ++numSubclassChecks;
      }

      // Check the cache
      if (VmSettings.USE_SUBTYPE_TABLE) {
        E result = checkTable(isSub, expected, argument, type, sourceSection, exception);
        if (result != null) {
          return result;
        }
      }

      if (VmSettings.COLLECT_TYPE_STATS) {
        ++numTypeCheckExecutions;
      }

      // Otherwise check if type check passes
      boolean result;
      if (argument == Nil.nilObject) {
        // Force nil object to subtype
        result = true;
      } else {
        result = expected.isSuperTypeOf(type, argument);
      }
      // Add the result to the cache
      if (isSub != null) {
        isSub[type.id] = result ? SUBTYPE : FAIL;
      }
      // Throw an error if the check didn't pass
      if (!result) {
        throwTypeError(argument, type, expected, sourceSection, exception);
      }
      // Otherwise return the argument
      return argument;
    }
/**
     * Check that for an argument, its type is a subtype of the expected type.
     */
Check that for an argument, its type is a subtype of the expected type.
Check that for an argument its type is a subtype of the expected type .
public <E> E check(final E argument, final SType type) {
      if (VmSettings.COLLECT_TYPE_STATS) {
        ++numSubclassChecks;
      }
      if (VmSettings.USE_SUBTYPE_TABLE) {
        E result = checkTable(isSub, expected, argument, type, sourceSection, exception);
        if (result != null) {
          return result;
        }
      }
      if (VmSettings.COLLECT_TYPE_STATS) {
        ++numTypeCheckExecutions;
      }
      boolean result;
      if (argument == Nil.nilObject) {
        result = true;
      } else {
        result = expected.isSuperTypeOf(type, argument);
      }
      if (isSub != null) {
        isSub[type.id] = result ? SUBTYPE : FAIL;
      }
      if (!result) {
        throwTypeError(argument, type, expected, sourceSection, exception);
      }
      return argument;
    }
public < E > E check ( final E argument , final SType type ) { if ( VmSettings . COLLECT_TYPE_STATS ) { ++ numSubclassChecks ; } if ( VmSettings . USE_SUBTYPE_TABLE ) { E result = checkTable ( isSub , expected , argument , type , sourceSection , exception ) ; if ( result != null ) { return result ; } } if ( VmSettings . COLLECT_TYPE_STATS ) { ++ numTypeCheckExecutions ; } boolean result ; if ( argument == Nil . nilObject ) { result = true ; } else { result = expected . isSuperTypeOf ( type , argument ) ; } if ( isSub != null ) { isSub [ type . id ] = result ? SUBTYPE : FAIL ; } if ( ! result ) { throwTypeError ( argument , type , expected , sourceSection , exception ) ; } return argument ; }
Check that for an argument, its type is a subtype of the expected type.
Check that for an argument its type is a subtype of the expected type .
// Check the cache // Otherwise check if type check passes // Force nil object to subtype // Add the result to the cache // Throw an error if the check didn't pass // Otherwise return the argument