Convert a c::value to an c$::expr.
Function:
(defun value-to-expr (value) (declare (xargs :guard (c::valuep value))) (let ((__function__ 'value-to-expr)) (declare (ignorable __function__)) (c::value-case value :uchar (expr-const (c$::const-int (c$::make-iconst :core (if (zp value.get) (dec/oct/hex-const-oct 1 0) (c$::dec/oct/hex-const-dec value.get)) :suffix? (c$::isuffix-u (c$::usuffix-locase-u))))) :schar (if (minusp value.get) (make-expr-unary :op (c::unop-minus) :arg (expr-const (c$::const-int (c$::make-iconst :core (c$::dec/oct/hex-const-dec (- value.get)))))) (expr-const (c$::const-int (c$::make-iconst :core (if (zp value.get) (dec/oct/hex-const-oct 1 0) (c$::dec/oct/hex-const-dec value.get)))))) :ushort (expr-const (c$::const-int (c$::make-iconst :core (if (zp value.get) (dec/oct/hex-const-oct 1 0) (c$::dec/oct/hex-const-dec value.get)) :suffix? (c$::isuffix-u (c$::usuffix-locase-u))))) :sshort (if (minusp value.get) (make-expr-unary :op (c::unop-minus) :arg (expr-const (c$::const-int (c$::make-iconst :core (c$::dec/oct/hex-const-dec (- value.get)))))) (expr-const (c$::const-int (c$::make-iconst :core (if (zp value.get) (dec/oct/hex-const-oct 1 0) (c$::dec/oct/hex-const-dec value.get)))))) :uint (expr-const (c$::const-int (c$::make-iconst :core (if (zp value.get) (dec/oct/hex-const-oct 1 0) (c$::dec/oct/hex-const-dec value.get)) :suffix? (c$::isuffix-u (c$::usuffix-locase-u))))) :sint (if (minusp value.get) (make-expr-unary :op (c::unop-minus) :arg (expr-const (c$::const-int (c$::make-iconst :core (c$::dec/oct/hex-const-dec (- value.get)))))) (expr-const (c$::const-int (c$::make-iconst :core (if (zp value.get) (dec/oct/hex-const-oct 1 0) (c$::dec/oct/hex-const-dec value.get)))))) :ulong (expr-const (c$::const-int (c$::make-iconst :core (if (zp value.get) (dec/oct/hex-const-oct 1 0) (c$::dec/oct/hex-const-dec value.get)) :suffix? (c$::isuffix-ul (c$::usuffix-locase-u) (c$::lsuffix-locase-l))))) :slong (if (minusp value.get) (make-expr-unary :op (c::unop-minus) :arg (expr-const (c$::const-int (c$::make-iconst :core (c$::dec/oct/hex-const-dec (- value.get)) :suffix? (c$::isuffix-l (c$::lsuffix-locase-l)))))) (expr-const (c$::const-int (c$::make-iconst :core (if (zp value.get) (dec/oct/hex-const-oct 1 0) (c$::dec/oct/hex-const-dec value.get)) :suffix? (c$::isuffix-l (c$::lsuffix-locase-l)))))) :ullong (expr-const (c$::const-int (c$::make-iconst :core (if (zp value.get) (dec/oct/hex-const-oct 1 0) (c$::dec/oct/hex-const-dec value.get)) :suffix? (c$::isuffix-ul (c$::usuffix-locase-u) (c$::lsuffix-locase-ll))))) :sllong (if (minusp value.get) (make-expr-unary :op (c::unop-minus) :arg (expr-const (c$::const-int (c$::make-iconst :core (c$::dec/oct/hex-const-dec (- value.get)) :suffix? (c$::isuffix-l (c$::lsuffix-locase-ll)))))) (expr-const (c$::const-int (c$::make-iconst :core (if (zp value.get) (dec/oct/hex-const-oct 1 0) (c$::dec/oct/hex-const-dec value.get)) :suffix? (c$::isuffix-l (c$::lsuffix-locase-ll)))))) :pointer (prog2$ (raise "TODO: pointer case not yet implemented") (irr-expr)) :array (prog2$ (raise "TODO: array case not yet implemented") (irr-expr)) :struct (prog2$ (raise "TODO: struct case not yet implemented") (irr-expr)))))
Theorem:
(defthm exprp-of-value-to-expr (b* ((expr (value-to-expr value))) (exprp expr)) :rule-classes :rewrite)