node/lib/metasm/metasm/cpu/x86_64/compile_c.rb
def c_init_state(func)
		@state = State.new(func)
		args = func.type.args.dup
		if @parser.lexer.definition['__MS_X86_64_ABI__']
			@state.args_space = 32
			@state.regargs = [1, 2, 8, 9]
		else
			@state.args_space = 0
			@state.regargs = [7, 6, 2, 1, 8, 9]
		end
		c_reserve_stack(func.initializer)
		off = @state.offset.values.max.to_i
		off = 0 if off < 0

		argoff = 2*8 + @state.args_space
		rlist = @state.regargs.dup
		args.each { |a|
			if a.has_attribute_var('register')
				off = c_reserve_stack_var(a, off)
				@state.offset[a] = off
			elsif r = rlist.shift
				if @state.args_space > 0
					# use reserved space to spill regargs
					off = -16-8*@state.regargs.index(r)
				else
					off = c_reserve_stack_var(a, off)
				end
				@state.offset[a] = off
			else
				@state.offset[a] = -argoff
				argoff = (argoff + sizeof(a) + 7) / 8 * 8
			end
		}
		if not @state.offset.values.grep(::Integer).empty?
			@state.saved_rbp = Reg.new(5, @cpusz)
			@state.used << 5
		end
	end
# holds compiler state information for a function
# registers are saved as register number (see Reg)
holds compiler state information for a function
registers are saved as register number
holds compiler state information for a function registers are saved as register number
def c_init_state(func)
		@state = State.new(func)
		args = func.type.args.dup
		if @parser.lexer.definition['__MS_X86_64_ABI__']
			@state.args_space = 32
			@state.regargs = [1, 2, 8, 9]
		else
			@state.args_space = 0
			@state.regargs = [7, 6, 2, 1, 8, 9]
		end
		c_reserve_stack(func.initializer)
		off = @state.offset.values.max.to_i
		off = 0 if off < 0
		argoff = 2*8 + @state.args_space
		rlist = @state.regargs.dup
		args.each { |a|
			if a.has_attribute_var('register')
				off = c_reserve_stack_var(a, off)
				@state.offset[a] = off
			elsif r = rlist.shift
				if @state.args_space > 0
					off = -16-8*@state.regargs.index(r)
				else
					off = c_reserve_stack_var(a, off)
				end
				@state.offset[a] = off
			else
				@state.offset[a] = -argoff
				argoff = (argoff + sizeof(a) + 7) / 8 * 8
			end
		}
		if not @state.offset.values.grep(::Integer).empty?
			@state.saved_rbp = Reg.new(5, @cpusz)
			@state.used << 5
		end
	end
def c_init_state ( func ) @state = State . new ( func ) args = func . type . args . dup if @parser . lexer . definition [ '__MS_X86_64_ABI__' ] @state . args_space = 32 @state . regargs = [ 1 , 2 , 8 , 9 ] else @state . args_space = 0 @state . regargs = [ 7 , 6 , 2 , 1 , 8 , 9 ] end c_reserve_stack ( func . initializer ) off = @state . offset . values . max . to_i off = 0 if off < 0 argoff = 2 * 8 + @state . args_space rlist = @state . regargs . dup args . each { | a | if a . has_attribute_var ( 'register' ) off = c_reserve_stack_var ( a , off ) @state . offset [ a ] = off elsif r = rlist . shift if @state . args_space > 0 off = - 16 - 8 * @state . regargs . index ( r ) else off = c_reserve_stack_var ( a , off ) end @state . offset [ a ] = off else @state . offset [ a ] = - argoff argoff = ( argoff + sizeof ( a ) + 7 ) / 8 * 8 end } if not @state . offset . values . grep ( :: Integer ) . empty? @state . saved_rbp = Reg . new ( 5 , @cpusz ) @state . used << 5 end end
holds compiler state information for a function
registers are saved as register number (see Reg)
holds compiler state information for a function registers are saved as register number ( see Reg )
# use reserved space to spill regargs
func