node/lib/metasm/metasm/parse.rb
# returns the array of token resulting from the application of the macro
# parses arguments if needed, handles macro-local labels
returns the array of token resulting from the application of the macro
parses arguments if needed, handles macro-local labels
returns the array of token resulting from the application of the macro parses arguments if needed handles macro - local labels
def apply(macro, lexer, program)
			args = Preprocessor::Macro.parse_arglist(lexer).to_a
			raise @name, 'invalid argument count' if args.length != @args.length
			labels = @labels.inject({}) { |h, l| h.update l => program.new_label(l) }
			args = @args.zip(args).inject({}) { |h, (fa, a)| h.update fa.raw => a }
			@body.map { |t|
				t = t.dup
				t.backtrace += macro.backtrace[-2..-1] if not macro.backtrace.empty?
				if labels[t.raw]
					t.raw = labels[t.raw]
					t
				elsif args[t.raw]
					args[t.raw]
				else
					t
				end
			}.flatten
		end
def apply ( macro , lexer , program ) args = Preprocessor :: Macro . parse_arglist ( lexer ) . to_a raise @name , 'invalid argument count' if args . length != @args . length labels = @labels . inject ( { } ) { | h , l | h . update l => program . new_label ( l ) } args = @args . zip ( args ) . inject ( { } ) { | h , ( fa , a ) | h . update fa . raw => a } @body . map { | t | t = t . dup t . backtrace += macro . backtrace [ - 2 .. - 1 ] if not macro . backtrace . empty? if labels [ t . raw ] t . raw = labels [ t . raw ] t elsif args [ t . raw ] args [ t . raw ] else t end } . flatten end
returns the array of token resulting from the application of the macro
parses arguments if needed, handles macro-local labels
returns the array of token resulting from the application of the macro parses arguments if needed handles macro - local labels
# apply macro # XXX update toks backtrace ?
macro
lexer
program