从 class<T> 中提取 T 并在 class 建筑中使用 T

Extract T from class<T> and use T in class building

我想使用从 Type.resolveClass() 获得的 Class<T> 并使用它在 class 中构建类型 T 的变量。我不太确定如何描述它,所以这里有一些代码希望能够很好地描述它。

public static function build(name:String) { 
var fields = Context.getBuildFields();
// Get Class<T>
var resolved = Type.resolveClass(name); 

// Do some magic to get a ComplexType that represents the T in Class<T>
var type = magic(resolved); // I want to find out how to do this

// Create a field of type T
fields.push({
  name: "ofTypeName",
  pos: Context.currentPos(),
  access: [AStatic, APublic],
  kind: FVar(type, macro null)
});


return fields;
}

所以我想知道如何从 Class<T> 中得到一个 ComplexType 代表 T

var type = Context.getType(name);
var ctype = TypeTools.toComplexType(type);