[decompiler] Make addition nicer (#733)

* temp

* update refs

* update reference

* fix tests
This commit is contained in:
water111
2021-08-01 18:24:58 -04:00
committed by GitHub
parent e70d179496
commit 12446037bd
42 changed files with 294 additions and 536 deletions
+10 -19
View File
@@ -516,10 +516,7 @@
int
(+
(-> obj type size)
(the-as
uint
(* (-> obj allocated-length) (the-as int (-> obj type heap-base)))
)
(* (-> obj allocated-length) (the-as int (-> obj type heap-base)))
)
)
)
@@ -536,14 +533,11 @@
type-to-make
(the-as
int
(+
(-> type-to-make size)
(the-as uint (* len (if (type-type? content-type number)
(the-as int (-> content-type size))
4
)
)
)
(+ (-> type-to-make size) (* len (if (type-type? content-type number)
(the-as int (-> content-type size))
4
)
)
)
)
)
@@ -775,13 +769,10 @@
int
(+
(-> array size)
(the-as
uint
(* (-> obj allocated-length) (if (type-type? (-> obj content-type) number)
(the-as int (-> obj content-type size))
4
)
)
(* (-> obj allocated-length) (if (type-type? (-> obj content-type) number)
(the-as int (-> obj content-type size))
4
)
)
)
)
+10 -29
View File
@@ -116,17 +116,11 @@
)
((=
(-> a2-0 heap-cur)
(+
(+ (+ (-> obj stack-size) -4) (the-as int (-> obj type size)))
(the-as int obj)
)
(+ (+ (-> obj stack-size) -4 (-> obj type size)) (the-as int obj))
)
(set!
(-> a2-0 heap-cur)
(the-as
pointer
(+ (+ (+ arg0 -4) (the-as int (-> obj type size))) (the-as int obj))
)
(the-as pointer (+ (+ arg0 -4 (-> obj type size)) (the-as int obj)))
)
(set! (-> obj stack-size) arg0)
)
@@ -193,7 +187,7 @@
;; definition for method 5 of type cpu-thread
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of cpu-thread ((obj cpu-thread))
(the-as int (+ (-> obj type size) (the-as uint (-> obj stack-size))))
(the-as int (+ (-> obj type size) (-> obj stack-size)))
)
;; definition for function remove-exit
@@ -364,7 +358,7 @@
(object-new
allocation
type-to-make
(the-as int (+ (-> process size) (the-as uint arg1)))
(the-as int (+ (-> process size) arg1))
)
(+ (the-as int allocation) 4)
)
@@ -473,7 +467,7 @@
(format #t "~Theap-top: #x~X~%" (-> obj heap-top))
(format #t "~Theap-cur: #x~X~%" (-> obj heap-cur))
(let ((s5-0 *print-column*))
(set! *print-column* (+ *print-column* (the-as uint 64)))
(set! *print-column* (+ *print-column* 64))
(format #t "----~%")
(inspect-process-heap obj)
(format #t "----~%")
@@ -487,7 +481,7 @@
;; definition for method 5 of type process
;; INFO: Return type mismatch uint vs int.
(defmethod asize-of process ((obj process))
(the-as int (+ (-> process size) (the-as uint (-> obj allocated-length))))
(the-as int (+ (-> process size) (-> obj allocated-length)))
)
;; definition for method 2 of type process
@@ -641,10 +635,7 @@
type-to-make
(the-as
int
(+
(+ (-> type-to-make size) (the-as uint (logand -16 (+ (* 12 arg1) 15))))
(the-as uint arg2)
)
(+ (-> type-to-make size) (logand -16 (+ (* 12 arg1) 15)) arg2)
)
)
)
@@ -676,7 +667,7 @@
(set! (-> obj first-shrink) #f)
(set!
(-> obj heap base)
(the-as pointer (logand -16 (+ (+ (the-as int obj) 115) (* 12 arg1))))
(the-as pointer (logand -16 (+ (the-as int obj) 115 (* 12 arg1))))
)
(set! (-> obj heap current) (-> obj heap base))
(set! (-> obj heap top) (&+ (-> obj heap base) arg2))
@@ -693,10 +684,7 @@
((obj dead-pool-heap) (arg0 dead-pool-heap-rec))
(the-as pointer (if (-> arg0 process)
(+
(+
(+ (-> arg0 process allocated-length) -4)
(the-as int (-> process size))
)
(+ (-> arg0 process allocated-length) -4 (-> process size))
(the-as int (-> arg0 process))
)
(-> obj heap base)
@@ -861,14 +849,7 @@
(let ((s4-0 (-> obj dead-list next))
(s3-0 (the-as process #f))
)
(let
((s1-0
(find-gap-by-size
obj
(the-as int (+ (-> process size) (the-as uint arg1)))
)
)
)
(let ((s1-0 (find-gap-by-size obj (the-as int (+ (-> process size) arg1)))))
(cond
((and s4-0 s1-0)
(set! (-> obj dead-list next) (-> s4-0 next))
@@ -16,7 +16,7 @@
;; definition for method 5 of type string
(defmethod asize-of string ((obj string))
(+ (+ (-> obj allocated-length) 1) (the-as int (-> string size)))
(+ (-> obj allocated-length) 1 (-> string size))
)
;; definition for function copy-string<-string
@@ -46,7 +46,7 @@
(object-new
allocation
type-to-make
(+ (+ s2-1 1) (the-as int (-> type-to-make size)))
(+ s2-1 1 (-> type-to-make size))
)
)
)
@@ -57,11 +57,7 @@
(else
(let
((v0-2
(object-new
allocation
type-to-make
(+ (+ arg0 1) (the-as int (-> type-to-make size)))
)
(object-new allocation type-to-make (+ arg0 1 (-> type-to-make size)))
)
)
(set! (-> v0-2 allocated-length) arg0)
@@ -532,34 +528,16 @@
(>= (-> next-char-2 0) (the-as uint 65))
(>= (the-as uint 70) (-> next-char-2 0))
)
(set!
result
(the-as
int
(+ (+ (-> next-char-2 0) -55) (the-as uint (* result 16)))
)
)
(set! result (the-as int (+ (-> next-char-2 0) -55 (* result 16))))
)
((and
(>= (-> next-char-2 0) (the-as uint 97))
(>= (the-as uint 102) (-> next-char-2 0))
)
(set!
result
(the-as
int
(+ (+ (-> next-char-2 0) -87) (the-as uint (* result 16)))
)
)
(set! result (the-as int (+ (-> next-char-2 0) -87 (* result 16))))
)
(else
(set!
result
(the-as
int
(+ (+ (-> next-char-2 0) -48) (the-as uint (* result 16)))
)
)
(set! result (the-as int (+ (-> next-char-2 0) -48 (* result 16))))
)
)
(set! next-char-2 (&-> next-char-2 1))
@@ -573,10 +551,7 @@
(>= (-> a0-4 0) (the-as uint 48))
(>= (the-as uint 49) (-> a0-4 0))
)
(set!
result
(the-as int (+ (+ (-> a0-4 0) -48) (the-as uint (* result 2))))
)
(set! result (the-as int (+ (-> a0-4 0) -48 (* result 2))))
(set! a0-4 (&-> a0-4 1))
)
)
@@ -594,10 +569,7 @@
(>= (-> str-ptr 0) (the-as uint 48))
(>= (the-as uint 57) (-> str-ptr 0))
)
(set!
result
(the-as int (+ (+ (-> str-ptr 0) -48) (the-as uint (* 10 result))))
)
(set! result (the-as int (+ (-> str-ptr 0) -48 (* 10 result))))
(set! str-ptr (&-> str-ptr 1))
)
)