Browse Source

don't reset types if they are already defined (hot reload)

Nicolas Cannasse 3 years ago
parent
commit
651ecf377a
1 changed files with 8 additions and 2 deletions
  1. 8 2
      std/hl/_std/Type.hx

+ 8 - 2
std/hl/_std/Type.hx

@@ -46,7 +46,10 @@ class Type {
 	}
 	}
 
 
 	@:keep static function initClass(ct:hl.Type, t:hl.Type, name:hl.Bytes):hl.BaseType.Class@:privateAccess {
 	@:keep static function initClass(ct:hl.Type, t:hl.Type, name:hl.Bytes):hl.BaseType.Class@:privateAccess {
-		var c:hl.BaseType.Class = ct.allocObject();
+		var c:hl.BaseType.Class = cast t.getGlobal();
+		if( c != null )
+			return c;
+		c = ct.allocObject();
 		t.setGlobal(c);
 		t.setGlobal(c);
 		c.__type__ = t;
 		c.__type__ = t;
 		c.__name__ = String.fromUCS2(name);
 		c.__name__ = String.fromUCS2(name);
@@ -55,7 +58,10 @@ class Type {
 	}
 	}
 
 
 	@:keep static function initEnum(et:hl.Type, t:hl.Type):hl.BaseType.Enum@:privateAccess {
 	@:keep static function initEnum(et:hl.Type, t:hl.Type):hl.BaseType.Enum@:privateAccess {
-		var e:hl.BaseType.Enum = et.allocObject();
+		var e:hl.BaseType.Enum = cast t.getGlobal();
+		if( e != null )
+			return e;
+		e = et.allocObject();
 		e.__type__ = t;
 		e.__type__ = t;
 		e.__evalues__ = t.getEnumValues();
 		e.__evalues__ = t.getEnumValues();
 		e.__ename__ = t.getTypeName();
 		e.__ename__ = t.getTypeName();