So I've also been having a go at writing an aml parser.. apart from the lack of clarity in the spec ( a lot of which can be overcome by generating sample asl files and compiling them to AML ) the following has occurred to me:
1.) IASL is NOT a compiler, it's a translator.. the resulting AML still contains un-evaluated expressions (granted in prefix order).
2.) ASL allows forward references, so a multi-pass approach is required.
3.) The problem with the aml is that due to it's nature you're not actually writing an interpreter but rather a bizarre combination of compiler/interpreter.. parts of the compilation depend on actually executing code, while some of the execution depends on the compilation (for example evaluation of symbols)
4.) In general the language is complete cr*p and the following is totally valid and compilable ASL:
Code: Select all
DefinitionBlock ("test.aml", "DSDT", 2, "DELL ", "IVB-CPT", 0x00000000)
{
If(SS1)
{
Name(SS2,1)
}
If(SS2)
{
Name(SS1,1)
}
}
I challenge anyone to parse that properly..
The only thing I can assume (as the spec doesn't say) is that the runtime might assume no forward references are valid.. I guess it depends on who wrote the ASL (firmware manufacturer) ?
in which case.. the first If would fail because SS1 isn't defined.. then the second If would also fail because SS2 isn't defined.. so the net result of that code wouldn't be a circular-reference (which would reach maximum passes and fail)
but rather that simply both blocks would be skipped.