What, may I ask, are you trying to DO with the instance of "A_TYPE" that you create...?
Types which are described by the symbols of what you are debugging only exist at some location IN the target. They can be at some virtual address in the target's address space... or they can be in some register of a thread or stack frame's context. You cannot just "create an instance" of A_TYPE described by symbols from JavaScript data.
You can create use host.createTypedObject method to say "there is an A_TYPE typed object at virtual address 0x1000 (or whatever) in the address space of the target. You can then read/write fields of that object through what you get back from the createTypedObject method call. That said -- if you write -- you are modifying the address space of the target process.
I'll note that things like host.typeSystem.marshalAs are designed to allow you to change how some object exits JavaScript. If, for instance, you bring a native enum value into JavaScript -- it will lose it's "enumness" and just become a number (there are no custom value types in JS). You cannot, therefore create a property that does something like:
// A property accessor on some class which returns a native enum...
get myValue()
{
return this.someEnum;
}
The moment someEnum enters JavaScript above, it becomes a number... and that number would get returned. If you really wanted an enum to get returned to the caller, you would need to use host.typeSystem.marshalAs to tell the marshaler that this number should be marshaled out of JavaScript as a specifically typed enum and not just a flat number.
UPDATED PER YOUR COMMENT (re decoding an in-memory A_TYPE):
While you cannot create an instance of A_TYPE from synthetic data, there are two ways to present something like the "decoded" type you are talking about. First is just to return a JavaScript object:
function decodeAType(aType)
{
// your extraction code...
var buf = new UInt8Array(...);
// Just return a JavaScript object
return { a: decoded_a, b: decoded_b, c: buf };
}
That returned object will work in the EE (dx) and can be passed to and used in any other C++ or JavaScript debugger extension. Yes -- it's not a "real type" and can't be used in legacy commands like 'dt', etc... but it's pretty functional.
The second way is to associate a visualizer with A_TYPE which does the decoding and presents the decoded fields:
class __MyATypeVisualizer
{
get decoded_a() { ... }
get decoded_b() { ... }
get decoded_c() { ... }
}
function initializeScript()
{
//
// Make __MyATypeVisualizer the canonical visualizer for A_TYPE.
// Any time it's displayed in the locals window or 'dx', the fields
// in __MyATypeVisualizer will be shown instead of the native fields.
// You can also use typeSignatureExtension below if you want those
// fields to be added instead of displayed in lieu of the native ones.
//
return [new host.typeSignatureRegistration(__MyATypeVisualizer, "A_TYPE")];
}
Here, the original A_TYPE can be passed around and used like a regular typed object... but when DISPLAYED in the locals or watch window... or in the console via dx, you'll see the added/visualized decoded fields. If the object is passed to another C++/JavaScript debugger extension, the fields added/visualized by __MyATypeVisualizer can be used just like the native ones... The same goes for the expression evaluator in 'dx'.
I hope that helps...