SymInfo* Info; /* Pointer to label symbol */
} Label;
Collection SpanInfoList; /* List of spans for this scope */
+ Collection* ChildScopes; /* Child scopes of this scope */
char Name[1]; /* Name of scope */
};
/* Initialize the fields as necessary */
CollInit (&S->SpanInfoList);
+ S->ChildScopes = 0;
memcpy (S->Name, SB_GetConstBuf (Name), SB_GetLen (Name) + 1);
/* Return it */
/* Free a ScopeInfo struct */
{
CollDone (&S->SpanInfoList);
+ CollFree (S->ChildScopes);
xfree (S);
}
S->Parent.Info = 0;
} else {
S->Parent.Info = CollAt (&D->Info->ScopeInfoById, S->Parent.Id);
+
+ /* Set a backpointer in the parent */
+ if (S->Parent.Info->ChildScopes == 0) {
+ S->Parent.Info->ChildScopes = CollNew ();
+ }
+ CollAppend (S->Parent.Info->ChildScopes, S);
}
/* Resolve the label */
CopyScopeInfo (D->data + I, CollConstAt (&M->ScopeInfoByName, I));
}
+ /* Return the result */
+ return D;
+}
+
+
+
+const cc65_scopeinfo* cc65_childscopes_byid (cc65_dbginfo Handle, unsigned Id)
+/* Return the direct child scopes of a scope with a given id. The function
+ * returns NULL if no scope with this id was found, otherwise a list of the
+ * direct childs.
+ */
+{
+ DbgInfo* Info;
+ cc65_scopeinfo* D;
+ ScopeInfo* S;
+ unsigned I;
+
+ /* Check the parameter */
+ assert (Handle != 0);
+
+ /* The handle is actually a pointer to a debug info struct */
+ Info = (DbgInfo*) Handle;
+
+ /* Check if the id is valid */
+ if (Id >= CollCount (&Info->ScopeInfoById)) {
+ return 0;
+ }
+
+ /* Get the scope */
+ S = CollAt (&Info->ScopeInfoById, Id);
+
+ /* Allocate memory for the data structure returned to the caller */
+ D = new_cc65_scopeinfo (S->ChildScopes? CollCount (S->ChildScopes) : 0);
+
+ /* Fill in the data */
+ for (I = 0; I < D->count; ++I) {
+ CopyScopeInfo (D->data + I, CollConstAt (S->ChildScopes, I));
+ }
/* Return the result */
return D;
* scope with the given id was found.
*/
+const cc65_scopeinfo* cc65_childscopes_byid (cc65_dbginfo handle, unsigned id);
+/* Return the direct child scopes of a scope with a given id. The function
+ * returns NULL if no scope with this id was found, otherwise a list of the
+ * direct childs.
+ */
+
void cc65_free_scopeinfo (cc65_dbginfo Handle, const cc65_scopeinfo* Info);
/* Free a scope info record */