The StackTraceInfo class
provides an author with a means of analyzing the TADS 3 stack trace facility
and is especially useful for determining whether an action is involved in the
call chain before the globals have been set by the library.
Proteus uses it in
conjunction with the memory module to determine whether the action being evaluated is one of the
diagnostic actions, at which point we bypass the normal memory requirements of
topics.
To take advantage of this
class simply create an instance with
the new operator:
local x = new StackTraceInfo();
If we were to examine the
stack produced by the command <<@purloin dagger>> in the memory.t module’s knowsTopic() method for the Actor class,
we might retrieve the following stack information from our StackTraceInfo instance:
stack_ = [obj#2ec1 (T3StackInfo),obj#2ea3
(T3StackInfo),obj#2e84 (T3StackInfo),obj#2e67 (T3StackInfo),obj#2e47
(T3StackInfo),obj#2e29 (T3StackInfo),obj#2e09 (T3StackInfo),obj#2df0
(T3StackInfo),obj#2ddb (T3StackInfo),obj#2dc7 (T3StackInfo),obj#2db2
(T3StackInfo),obj#2d9f (T3StackInfo),obj#2d8a (T3StackInfo),obj#2d76
(T3StackInfo),obj#2d61 (T3StackInfo),obj#2d4e (T3StackInfo),obj#2d39
(T3StackInfo),obj#2d25 (T3StackInfo),obj#2d10 (T3StackInfo),obj#2cfd
(T3StackInfo),obj#2ce8 (T3StackInfo),obj#2cd4 (T3StackInfo),obj#2c2a
(T3StackInfo),obj#2c12 (T3StackInfo),obj#2c05 (T3StackInfo),obj#2bf7
(T3StackInfo),obj#2be7 (T3StackInfo),obj#2bd9 (T3StackInfo),obj#2bcc
(T3StackInfo),obj#2bbe (T3StackInfo),obj#2bb1 (T3StackInfo)]
commandList =
[obj#29f9 (firstCommandPhrase(commandOnly)),obj#29b3
(commandPhrase(definiteConj))]
predicateList =
[obj#29a7 (predicate(PurloinObj))]
actionClassList
= [PurloinObjAction]
We now know that the library
is processing a PurloinObjAction, even though gAction has
not yet been set. We can query the StackTraceInfo
object further by sending the message hasDiagnosticAction() and determine whether this action is one of proteus’ diagnostic
actions. It is.
The StackTraceInfo class
provides the following attributes and methods:
This is a list of any
CommandPhrase class objects found in the stack trace.
This is a list of any Predicate class objects found in the stack trace.
This is a list of Action classes for any Predicate
class objects found in the stack trace.
This method returns true if there is a diagnostic action in the stack trace;
otherwise it returns nil.
The StackTraceInfo class makes use of the following additional methods
to the T3StackInfo class:
This method returns true if the T3StackInfo
object has a CommandPhrase class object; otherwise it returns nil.
This method returns true if the T3StackInfo
object has a Predicate class object, otherwise it returns nil.
If the T3StackInfo object has a Predicate
class object, then this method will return the first named ancestor that
represents the Action class for the command.
This file is part of the TADS 3
Proteus Library Extension
Copyright ©
2001-2004 Kevin Forchione. All rights reserved.