node/lib/metasm/metasm/cpu/ia32/compile_c.rb
# holds compiler state information for a function
# registers are saved as register number (see Ia32::Reg)
# TODO cache eflags ? or just z ? (may be defered to asm_optimize)
holds compiler state information for a function
registers are saved as register number
TODO cache eflags . or just z . (may be defered to asm_optimize)
holds compiler state information for a function registers are saved as register number TODO cache eflags . or just z . ( may be defered to asm_optimize )
def c_epilog
		return if @state.func.attributes.to_a.include? 'naked'
		@state.dirty.reverse_each { |reg|
			instr 'pop', Reg.new(reg, @cpusz)
		}
		if ebp = @state.saved_ebp
			instr 'mov', Reg.new(4, ebp.sz), ebp
			instr 'pop', ebp
		end
		f = @state.func
		if f.has_attribute('stdcall') or f.has_attribute('fastcall')
			al = typesize[:ptr]
			fa = f.type.args.dup
			2.times { fa.shift } if f.has_attribute('fastcall')
			argsz = fa.inject(0) { |sum, a|
				(a.has_attribute_var('register') or a.type.has_attribute_var('register')) ? sum : sum + (sizeof(a) + al - 1) / al * al
			}
			if argsz > 0
				instr 'ret', Expression[argsz]
			else
				instr 'ret'
			end
		else
			instr 'ret'
		end
	end
def c_epilog return if @state . func . attributes . to_a . include? 'naked' @state . dirty . reverse_each { | reg | instr 'pop' , Reg . new ( reg , @cpusz ) } if ebp = @state . saved_ebp instr 'mov' , Reg . new ( 4 , ebp . sz ) , ebp instr 'pop' , ebp end f = @state . func if f . has_attribute ( 'stdcall' ) or f . has_attribute ( 'fastcall' ) al = typesize [ :ptr ] fa = f . type . args . dup 2 . times { fa . shift } if f . has_attribute ( 'fastcall' ) argsz = fa . inject ( 0 ) { | sum , a | ( a . has_attribute_var ( 'register' ) or a . type . has_attribute_var ( 'register' ) ) ? sum : sum + ( sizeof ( a ) + al - 1 ) / al * al } if argsz > 0 instr 'ret' , Expression [ argsz ] else instr 'ret' end else instr 'ret' end end
holds compiler state information for a function
registers are saved as register number (see Ia32::Reg)
TODO cache eflags ?
holds compiler state information for a function registers are saved as register number ( see Ia32 :: Reg ) TODO cache eflags ?
# TODO revert dynamic array alloc