Something went wrong. Try again.
🌱 A minimal programming language and compiler. git.urbach.dev/cli/q
high-performance programming-language compiler
Something went wrong. Try again.
123456789101112131415161718192021222324252627package core
import ( "git.urbach.dev/cli/q/src/ssa" "git.urbach.dev/cli/q/src/token" "git.urbach.dev/cli/q/src/types")
// makeSlice creates a new slice.func (f *Function) makeSlice(address ssa.Value, from ssa.Value, to ssa.Value, source ssa.Source) *ssa.Struct { elementType := types.Unwrap(address.Type()).(*types.Pointer).To addressOffset := f.multiplySize(from, elementType.Size())
newPointer := f.Append(&ssa.BinaryOp{ Op: token.Add, Left: address, Right: addressOffset, })
newLength := f.Append(&ssa.BinaryOp{ Op: token.Sub, Left: to, Right: from, })
return f.makeStruct(f.Env.Slice(elementType), []ssa.Value{newPointer, newLength}, source)}