Improved thread creation on Linux

This commit is contained in:
2025-02-16 11:31:31 +01:00
parent d0bcd8cf9f
commit 00be603b8f
5 changed files with 39 additions and 5 deletions

@ -21,6 +21,7 @@ func (r *Result) finalize() {
}
final.Call("main.main")
final.Label(asm.LABEL, "_exit")
switch config.TargetOS {
case config.Linux:

@ -26,6 +26,11 @@ func (f *Function) ExpressionToMemory(node *expression.Expression, memory asm.Me
return types.AnyPointer, nil
}
if name == "_exit" {
f.MemoryLabel(asm.STORE, memory, "_exit")
return types.AnyPointer, nil
}
return nil, errors.New(&errors.UnknownIdentifier{Name: name}, f.File, node.Token.Position)
}

@ -27,6 +27,23 @@ func (f *Function) Fold(expr *expression.Expression) error {
return nil
}
if expr.Token.Kind == token.Period {
left := expr.Children[0]
leftText := left.Token.Text(f.File.Bytes)
right := expr.Children[1]
rightText := right.Token.Text(f.File.Bytes)
constant, isConst := f.Constants[f.Package+"."+leftText+"."+rightText]
if !isConst {
return nil
}
value, err := f.ToNumber(constant.Value)
expr.Value = value
expr.IsFolded = true
return err
}
canFold := true
for _, child := range expr.Children {