node/lib/metasm/metasm/cpu/x86_64/compile_c.rb
def findvar(var)
		if ret = @state.bound[var]
			return ret
		end

		if ret = @state.cache.index(var)
			ret = ret.dup
			inuse ret
			return ret
		end

		sz = 8*sizeof(var) rescue nil	# extern char foo[];

		case off = @state.offset[var]
		when C::CExpression
			# stack, dynamic address
			# TODO
			# no need to update state.cache here, never recursive
			v = raise "find dynamic addr of #{var.name}"
		when ::Integer
			# stack
			# TODO -fomit-frame-pointer ( => state.cache dependant on stack_offset... )
			v = ModRM.new(@cpusz, sz, nil, nil, @state.saved_rbp, Expression[-off])
		when nil
			# global
			if @exeformat.cpu.generate_PIC
				v = ModRM.new(@cpusz, sz, nil, nil, Reg.from_str('rip'), Expression[var.name, :-, '$_'])
			else
				v = ModRM.new(@cpusz, sz, nil, nil, nil, Expression[var.name])
			end
		end

		case var.type
		when C::Array; inuse Address.new(v)
		else inuse v
		end
	end
# returns a variable storage (ModRM for stack/global, Reg/Composite for register-bound)
returns a variable storage (ModRM for stack/global, Reg/Composite for register-bound)
returns a variable storage ( ModRM for stack / global Reg / Composite for register - bound )
def findvar(var)
		if ret = @state.bound[var]
			return ret
		end
		if ret = @state.cache.index(var)
			ret = ret.dup
			inuse ret
			return ret
		end
		sz = 8*sizeof(var) rescue nil	
		case off = @state.offset[var]
		when C::CExpression
			v = raise "find dynamic addr of #{var.name}"
		when ::Integer
			 -fomit-frame-pointer ( => state.cache dependant on stack_offset... )
			v = ModRM.new(@cpusz, sz, nil, nil, @state.saved_rbp, Expression[-off])
		when nil
			if @exeformat.cpu.generate_PIC
				v = ModRM.new(@cpusz, sz, nil, nil, Reg.from_str('rip'), Expression[var.name, :-, '$_'])
			else
				v = ModRM.new(@cpusz, sz, nil, nil, nil, Expression[var.name])
			end
		end
		case var.type
		when C::Array; inuse Address.new(v)
		else inuse v
		end
	end
def findvar ( var ) if ret = @state . bound [ var ] return ret end if ret = @state . cache . index ( var ) ret = ret . dup inuse ret return ret end sz = 8 * sizeof ( var ) rescue nil case off = @state . offset [ var ] when C :: CExpression v = raise "find dynamic addr of #{var.name}" when :: Integer v = ModRM . new ( @cpusz , sz , nil , nil , @state . saved_rbp , Expression [ - off ] ) when nil if @exeformat . cpu . generate_PIC v = ModRM . new ( @cpusz , sz , nil , nil , Reg . from_str ( 'rip' ) , Expression [ var . name , :- , '$_' ] ) else v = ModRM . new ( @cpusz , sz , nil , nil , nil , Expression [ var . name ] ) end end case var . type when C :: Array ; inuse Address . new ( v ) else inuse v end end
returns a variable storage (ModRM for stack/global, Reg/Composite for register-bound)
returns a variable storage ( ModRM for stack / global Reg / Composite for register - bound )
# extern char foo[]; # stack, dynamic address # TODO # no need to update state.cache here, never recursive # stack # TODO -fomit-frame-pointer ( => state.cache dependant on stack_offset... ) # global
var