(for programming language D)
I am trying to initialize an associative array with structure elements and should be indexed line by line. I would import it as a module from a separate file.
This is what I want to achieve (and it does not work --- I do not know if this is possible):
mnemonic_info[string] mnemonic_table = [
"ADD": {mnemonic_format.Format3M, 0x18},
...
];
Note that this works great for arrays indexed by integers.
Optimally, I would like this to be evaluated at compile time, since I won't change it. However, if this is not possible, I would be happy if you would tell me about the best way to build such an array in / before the immediate runtime.
I need this because I am writing assembler.
SO , , , .
D , , , - , .
!
: Tuples ?
Edit
, , :
mnemonic_info[string] mnemonic_table;
static this() {
mnemonic_info entry;
entry.format = mnemonic_format.Format3M;
entry.opcode = 0x18;
mnemonic_table["ADD"] = entry;
}