node@(Syntax Node traits) macroExpand "The default do-nothing action of macro expansion." [ node ]. ann@(Syntax Annotation traits) macroExpand "Return the annotation node, but replace the expression that the node annotates with its expansion." [| expansion | expansion: ann value macroExpand. ann value = expansion ifFalse: [ann value: expansion]. ann ]. macro@(Syntax Macro traits) macroExpand "Simply apply the macro-method to its arguments. The generated nodes inherit the macro node's debugging information." [| expansion | expansion: (macro selector sendTo: macro arguments) macroExpand. macro lineNumber ifNotNil: [expansion walk: [| :child | child lineNumber ifNil: [child lineNumber: macro lineNumber]]]. expansion ]. message@(Syntax Message traits) macroExpand "Replace each argument to the message with its macro-expanded value." [ message arguments doWithIndex: [| :argument :index expansion | expansion: argument macroExpand. argument = expansion ifFalse: [message arguments at: index put: expansion]]. message ]. opts@(Syntax OptionalKeywords traits) macroExpand "Replace each argument to the optional keywords with its macro-expanded value." [ opts arguments doWithIndex: [| :argument :index expansion | expansion: argument macroExpand. argument = expansion ifFalse: [opts arguments at: index put: expansion]]. opts ]. group@(Syntax CompoundStatement traits) macroExpand "Replace the group's contents with their macro-expansions. This covers: Arrays, Blocks, and Parentheses." [ group statements doWithIndex: [| :statement :index expansion | expansion: statement macroExpand. statement = expansion ifFalse: [group statements at: index put: expansion]]. group ]. method@(Syntax MethodDefinition traits) macroExpand "MethodDefinition nodes must handle the additional complication of roles." [ method roles doWithIndex: [| :role :index expansion | role ifNotNil: [expansion: role macroExpand. role = expansion ifFalse: [method roles at: index put: expansion]]]. resend ]. store@(Syntax StoreVariable traits) macroExpand "Expand the value to be stored." [| expansion | expansion: store value macroExpand. store value = expansion ifFalse: [store value: expansion]. store ]. ret@(Syntax Return traits) macroExpand "Expand the value to be returned." [| expansion | expansion: ret value macroExpand. ret value = expansion ifFalse: [ret value: expansion]. ret ].