summaryrefslogtreecommitdiff
path: root/src/modules/ast
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/ast')
-rw-r--r--src/modules/ast/assembly-tree.scm29
-rw-r--r--src/modules/ast/syntax-tree.scm47
2 files changed, 41 insertions, 35 deletions
diff --git a/src/modules/ast/assembly-tree.scm b/src/modules/ast/assembly-tree.scm
index ee3e116..3f0f1b1 100644
--- a/src/modules/ast/assembly-tree.scm
+++ b/src/modules/ast/assembly-tree.scm
@@ -4,22 +4,37 @@
subroutine?
subroutine-label
subroutine-instructions
+ subroutine-frame-size
make-instruction
instruction?
+ instruction-destination
+ set-instruction-destination
instruction-operator
- instruction-operand-1
- instruction-operand-2))
+ instruction-src-1
+ instruction-src-2
+
+ make-register
+ register?
+ register-name
+ ))
(define-record-type <subroutine>
- (make-subroutine label instrs)
+ (make-subroutine label instrs f-size)
subroutine?
(label subroutine-label)
- (instrs subroutine-instructions))
+ (instrs subroutine-instructions)
+ (f-size subroutine-frame-size))
(define-record-type <instruction>
- (make-instruction op oper1 oper2)
+ (make-instruction dest op src1 src2)
instruction?
+ (dest instruction-destination set-instruction-destination)
(op instruction-operator)
- (oper1 instruction-operand-1)
- (oper2 instruction-operand-2))
+ (src1 instruction-src-1)
+ (src2 instruction-src-2))
+
+(define-record-type <register>
+ (make-register name)
+ register?
+ (name register-name))
diff --git a/src/modules/ast/syntax-tree.scm b/src/modules/ast/syntax-tree.scm
index b7db8dd..e2ca8da 100644
--- a/src/modules/ast/syntax-tree.scm
+++ b/src/modules/ast/syntax-tree.scm
@@ -1,34 +1,30 @@
(define-module (modules ast syntax-tree)
#:use-module (srfi srfi-9)
#:export (make-program
- program?
- program-function
+ program?
+ program-function
- make-function
- function?
- function-id
- function-stmt
+ make-function
+ function?
+ function-id
+ function-stmt
- make-stmt
- stmt?
- stmt-expr
+ make-stmt
+ stmt?
+ stmt-expr
- make-expr
- expr?
- expr-type
+ make-unary
+ unary?
+ unary-operator
+ unary-expr
- make-unary
- unary?
- unary-operator
- unary-expr
+ make-const
+ const?
+ const-int
- make-const
- const?
- const-int
-
- make-id
- id?
- id-symbol))
+ make-id
+ id?
+ id-symbol))
(define-record-type <program>
(make-program func)
@@ -46,11 +42,6 @@
stmt?
(expr stmt-expr))
-(define-record-type <expr>
- (make-expr type)
- expr?
- (type expr-type))
-
(define-record-type <unary>
(make-unary op expr)
unary?