node/lib/metasm/metasm/cpu/ia32/compile_c.rb
def c_ifgoto(expr, target)
		case o = expr.op
		when :<, :>, :<=, :>=, :==, :'!='
			l = c_cexpr_inner(expr.lexpr)
			r = c_cexpr_inner(expr.rexpr)
			if l.kind_of? Expression
				o = { :< => :>, :> => :<, :>= => :<=, :<= => :>= }[o] || o
				l, r = r, l
			end
			r = make_volatile(r, expr.type) if r.kind_of? ModRM and l.kind_of? ModRM
			unuse l, r
			if expr.lexpr.type.integral?
				if expr.lexpr.type.name == :__int64 and @cpusz != 64
					raise # TODO
				end
				instr 'cmp', l, r
			elsif expr.lexpr.type.float?
				raise # TODO
				instr 'fcmpp', l, r
			else raise 'bad comparison ' + expr.to_s
			end
			op = 'j' + getcc(o, expr.lexpr.type)
			instr op, Expression[target]
		when :'!'
			r = c_cexpr_inner(expr.rexpr)
			r = make_volatile(r, expr.rexpr.type)
			unuse r
			instr 'test', r, r
			instr 'jz', Expression[target]
		else
			r = c_cexpr_inner(expr)
			r = make_volatile(r, expr.type)
			unuse r
			instr 'test', r, r
			instr 'jnz', Expression[target]
		end
	end
# 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_ifgoto(expr, target)
		case o = expr.op
		when :<, :>, :<=, :>=, :==, :'!='
			l = c_cexpr_inner(expr.lexpr)
			r = c_cexpr_inner(expr.rexpr)
			if l.kind_of? Expression
				o = { :< => :>, :> => :<, :>= => :<=, :<= => :>= }[o] || o
				l, r = r, l
			end
			r = make_volatile(r, expr.type) if r.kind_of? ModRM and l.kind_of? ModRM
			unuse l, r
			if expr.lexpr.type.integral?
				if expr.lexpr.type.name == :__int64 and @cpusz != 64
					raise 
				end
				instr 'cmp', l, r
			elsif expr.lexpr.type.float?
				raise 
				instr 'fcmpp', l, r
			else raise 'bad comparison ' + expr.to_s
			end
			op = 'j' + getcc(o, expr.lexpr.type)
			instr op, Expression[target]
		when :'!'
			r = c_cexpr_inner(expr.rexpr)
			r = make_volatile(r, expr.rexpr.type)
			unuse r
			instr 'test', r, r
			instr 'jz', Expression[target]
		else
			r = c_cexpr_inner(expr)
			r = make_volatile(r, expr.type)
			unuse r
			instr 'test', r, r
			instr 'jnz', Expression[target]
		end
	end
def c_ifgoto ( expr , target ) case o = expr . op when :< , :> , :<= , :>= , :== , :' != ' l = c_cexpr_inner ( expr . lexpr ) r = c_cexpr_inner ( expr . rexpr ) if l . kind_of? Expression o = { :< => :> , :> => :< , :>= => :<= , :<= => :>= } [ o ] || o l , r = r , l end r = make_volatile ( r , expr . type ) if r . kind_of? ModRM and l . kind_of? ModRM unuse l , r if expr . lexpr . type . integral? if expr . lexpr . type . name == :__int64 and @cpusz != 64 raise end instr 'cmp' , l , r elsif expr . lexpr . type . float? raise instr 'fcmpp' , l , r else raise 'bad comparison ' + expr . to_s end op = 'j' + getcc ( o , expr . lexpr . type ) instr op , Expression [ target ] when :' ! ' r = c_cexpr_inner ( expr . rexpr ) r = make_volatile ( r , expr . rexpr . type ) unuse r instr 'test' , r , r instr 'jz' , Expression [ target ] else r = c_cexpr_inner ( expr ) r = make_volatile ( r , expr . type ) unuse r instr 'test' , r , r instr 'jnz' , Expression [ target ] 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 # TODO
expr
target