nearly working, gotta get converting numbers to strings working

This commit is contained in:
SpookyDervish
2025-09-06 21:24:05 +10:00
parent 23ec72e961
commit 85a547780d
4 changed files with 62 additions and 17 deletions

View File

@@ -25,6 +25,8 @@ class IntNode:
value: float value: float
def __repr__(self): def __repr__(self):
return "Int" return "Int"
def __str__(self):
return str(self.value)
@dataclass @dataclass
class FloatNode: class FloatNode:
value: float value: float

BIN
out

Binary file not shown.

66
out.asm
View File

@@ -1,29 +1,67 @@
; ~~~ Auto generated by the GroundPY compiler for Linux x86_64 targets. ~~~ ; ~~~ Auto generated by the GroundPY compiler for Linux x86_64 targets. ~~~
section .data section .data
.LC0: db "Hello, World!", 10, 0 .LC0: db "123", 0
.LC1: equ $ - .LC0 .LC1: equ $ - .LC0
.LC2: db "", 10, "WE CAN PRINT FUCKING NUMBERS AND SHITT", 10, 0
.LC3: equ $ - .LC2
.LC4: db "LESS GOOOOO", 10, 0
.LC5: equ $ - .LC4
.LC6: db "this was printed using a variable!!!!!", 10, 0
.LC7: equ $ - .LC6
.LC8: db "", 10, 0
.LC9: equ $ - .LC8
section .text section .text
global _start global _start
_start: _start:
; InstructionNode(instruction='set', parent=RootNode(statements=[..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, String]) ; InstructionNode(instruction='stdout', parent=RootNode(statements=[..., InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[Int])
lea rax, [.LC0] mov rsi, .LC0
push rax mov rdx, .LC1
mov rax, .LC1
push rax
; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), ..., InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariablePointer, Int])
mov rax, 123
push rax
; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), ..., InstructionNode(instruction='end', parent=..., arguments=[VariableReference])]), arguments=[VariableReference])
mov rsi, [rsp + 16]
mov rdx, [rsp + 8]
mov rax, 1 mov rax, 1
mov rdi, 1 mov rdi, 1
syscall syscall
; InstructionNode(instruction='end', parent=RootNode(statements=[InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), ...]), arguments=[VariableReference]) ; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), ..., InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[String])
mov rsi, .LC2
mov rdx, .LC3
mov rax, 1
mov rdi, 1
syscall
; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), ..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[String])
mov rsi, .LC4
mov rdx, .LC5
mov rax, 1
mov rdi, 1
syscall
; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), ..., InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[VariablePointer, String])
lea rax, [.LC6]
push rax
mov rax, .LC7
push rax
; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), ..., InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[VariableReference])
mov rsi, [rsp + 8]
mov rdx, [rsp + 0]
mov rax, 1
mov rdi, 1
syscall
; InstructionNode(instruction='set', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), ..., InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[VariablePointer, Int])
mov rax, 123
push rax
; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), ..., InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[VariableReference])
mov rsi, [rsp + 0]
mov rdx, [rsp + -8]
mov rax, 1
mov rdi, 1
syscall
; InstructionNode(instruction='stdout', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), ..., InstructionNode(instruction='end', parent=..., arguments=[Int])]), arguments=[String])
mov rsi, .LC8
mov rdx, .LC9
mov rax, 1
mov rdi, 1
syscall
; InstructionNode(instruction='end', parent=RootNode(statements=[InstructionNode(instruction='stdout', parent=..., arguments=[Int]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, String]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='set', parent=..., arguments=[VariablePointer, Int]), InstructionNode(instruction='stdout', parent=..., arguments=[VariableReference]), InstructionNode(instruction='stdout', parent=..., arguments=[String]), ...]), arguments=[Int])
mov rax, 60 mov rax, 60
mov rdi, [rsp + 0] mov rdi, 0
syscall syscall

View File

@@ -1,4 +1,9 @@
set &x "Hello, World!\n" stdout 123
set &y 123 stdout "\nWE CAN PRINT FUCKING NUMBERS AND SHITT\n"
stdout "LESS GOOOOO\n"
set &x "this was printed using a variable!!!!!\n"
stdout $x stdout $x
end $y set &y 123
stdout $y
stdout "\n"
end 0