10.10. AST type usage collection

The AST_USED module implements analysis passes that determine which AST nodes are actually used in the program. This information is used for dead code elimination, tree shaking, and optimizing generated output.

All functions and symbols are in “ast_used” module, use require to get access to it.

require daslib/ast_used

10.10.1. Structures

ast_used::OnlyUsedTypes

Collection of all structure and enumeration types that are used in the AST.

Fields
  • st : table< Structure?;void> - all structure types used

  • en : table< Enumeration?;void> - all enumeration types used

10.10.2. Collecting type information

ast_used::collect_used_types(vfun: array<Function?>; vvar: array<Variable?>; blk: block<(usedTypes:OnlyUsedTypes):void>)

Goes through list of functions vfun and variables vvar and collects list of which enumeration and structure types are used in them. Calls blk with said list.

Arguments