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
.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 {
l := utils.NewLogger(os.Stderr, "[build] ", utils.Info)
l := utils.NewLogger(os.Stderr, "[build] ", utils.Debug)
nodes := make(map[int]*node)
rootNodes := []int{}

View File

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

View File

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

View File

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

View File

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