direnv and some arg fixes

This commit is contained in:
Robin Bärtschi 2025-03-07 16:38:14 +01:00
parent 45dad474e0
commit b633246af8
7 changed files with 15 additions and 8 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

1
.gitignore vendored
View File

@ -1 +1,2 @@
result result
.direnv

View File

@ -40,7 +40,7 @@ func NewSourceProgram(inputFile string, outputFile string) *SourceProgram {
} }
func (sp *SourceProgram) Build(backend asm.Backend, emitAsmOnly bool, toPrint ToPrintFlags) error { func (sp *SourceProgram) Build(backend asm.Backend, emitAsmOnly bool, toPrint ToPrintFlags) error {
l := utils.NewLogger(os.Stderr, "[build] ", utils.Info) l := utils.NewLogger(os.Stderr, "[build] ", utils.Debug)
nodes := make(map[int]*node) nodes := make(map[int]*node)
rootNodes := []int{} rootNodes := []int{}

View File

@ -110,6 +110,12 @@ func (l *Lexer) NextToken() token.Token {
case '*': case '*':
tok = l.newToken(token.Asterisk) tok = l.newToken(token.Asterisk)
case '/': case '/':
if l.peekByte() == '/' {
for l.ch != '\n' {
l.readChar()
}
return l.NextToken()
}
tok = l.newToken(token.Slash) tok = l.newToken(token.Slash)
case '{': case '{':
tok = l.newToken(token.OpenBrack) tok = l.newToken(token.OpenBrack)

View File

@ -8,10 +8,7 @@ fn main() = {
} }
}; };
fn test2(hello: i32,) = { fn test2(hello: i64,) = {
hello hello // Comment test
}; };
fn test2(hello: i32,) = {
hello
};

View File

@ -22,6 +22,7 @@ func (p *Program) String() string {
type Function struct { type Function struct {
Name string Name string
Arguments []string
Instructions []Instruction Instructions []Instruction
HasReturnValue bool HasReturnValue bool
} }

View File

@ -79,8 +79,9 @@ func VarResolve(p *ast.Program) (map[string]Scope, error) {
} }
s := Scope{Variables: make(map[string]Var)} s := Scope{Variables: make(map[string]Var)}
for _, arg := range d.Args { for i, arg := range d.Args {
s.SetUniq(arg.Name) uniq := s.SetUniq(arg.Name)
d.Args[i].Name = uniq
} }
err := VarResolveExpr(&s, d.Body) err := VarResolveExpr(&s, d.Body)
functionToScope[d.Name] = s functionToScope[d.Name] = s