mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
correct type hierarchy in isSubTypeOf()
This commit is contained in:
parent
1f51fbf036
commit
09ab338aa7
@ -49,9 +49,9 @@ public interface AnyType {
|
|||||||
/**
|
/**
|
||||||
* Check if this is a sub type of given type.
|
* Check if this is a sub type of given type.
|
||||||
*
|
*
|
||||||
* @param type
|
* @param other
|
||||||
* type to check
|
* type to check
|
||||||
* @return true, if both are identical or the type is a sub type
|
* @return true, if both are identical or this is a sub type of <code>other</code>. Or if <code>other</code> is a parent type of this.
|
||||||
*/
|
*/
|
||||||
public boolean isSubTypeOf( @Nonnull AnyType type );
|
public boolean isSubTypeOf( @Nonnull AnyType other );
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2017 - 2020 Volker Berlin (i-net software)
|
* Copyright 2017 - 2022 Volker Berlin (i-net software)
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -29,8 +29,8 @@ public enum ValueType implements AnyType {
|
|||||||
i16(-0x07),
|
i16(-0x07),
|
||||||
u16(-0x07),
|
u16(-0x07),
|
||||||
funcref(-0x10),
|
funcref(-0x10),
|
||||||
externref(-0x11),
|
externref(-0x11), //TODO rename to any
|
||||||
anyref(-0x12),
|
anyref(-0x12), // TODO obsolete
|
||||||
eqref(-0x13),
|
eqref(-0x13),
|
||||||
optref(-0x14),
|
optref(-0x14),
|
||||||
ref(-0x15),
|
ref(-0x15),
|
||||||
@ -76,6 +76,16 @@ public enum ValueType implements AnyType {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isSubTypeOf( AnyType type ) {
|
public boolean isSubTypeOf( AnyType type ) {
|
||||||
return type == this;
|
if( type == this ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
switch( this ) {
|
||||||
|
case externref:
|
||||||
|
return type.isRefType();
|
||||||
|
case eqref:
|
||||||
|
return type.isRefType() || type == externref;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user