I’m writing a ActionScript ByteCode parser in an the specs say to obtain the object at the bottom of the stack. Now as far as I can tell the bottom of the stack in the ActionScript Virtual Machine (AVM) is the object that was pushed first onto the stack. I’d really like to avoid popping all the items off the stack just to get to the bottom. Does anyone know if obtaining the bottom item is possible? If not, its some freaky stuff the AVM does 😛
Thanks, Josh
What you are trying to do is against the purpose of stack. However you can write a wrapper class.
When Push method called and the stack is empty add it object to stack and also keep a reference in your class. When Pop method called and the stack has only one object clear reference you keep.