Skip to content

Commit

Permalink
Rolled back array pointer changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
markkurossi committed Aug 2, 2022
1 parent 372927b commit be3e504
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 30 deletions.
18 changes: 9 additions & 9 deletions compiler/ast/builtin.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ func copySSA(block *ssa.Block, ctx *Codegen, gen *ssa.Generator,
var elementType types.Info

switch dst.Type.Type {
// case types.TArray:
// baseName = dst.Name
// baseType = dst.Type
// baseScope = dst.Scope
// baseBindings = block.Bindings
//
// dstOffset = 0
// elementType = *dst.Type.ElementType
// base = dst
case types.TArray:
baseName = dst.Name
baseType = dst.Type
baseScope = dst.Scope
baseBindings = block.Bindings

dstOffset = 0
elementType = *dst.Type.ElementType
base = dst

case types.TPtr:
elementType = *dst.Type.ElementType
Expand Down
23 changes: 2 additions & 21 deletions compiler/ast/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,28 +567,9 @@ func (ast *Make) Eval(env *Env, ctx *Codegen, gen *ssa.Generator) (
typeInfo.ArraySize = length
typeInfo.Bits = typeInfo.ElementType.Bits * length
typeInfo.MinBits = typeInfo.Bits
v := gen.AnonVal(typeInfo)

// Allocate array from heap.
array := gen.NewVal(ctx.HeapVar(), typeInfo, 0)
ctx.Package.Bindings.Set(array, nil)

// Return pointer to array.
ptr := gen.AnonVal(types.Info{
Type: types.TPtr,
Bits: array.Type.Bits,
MinBits: array.Type.Bits,
ElementType: &array.Type,
})
ptr.PtrInfo = &ssa.PtrInfo{
Name: array.Name,
Bindings: ctx.Package.Bindings,
Scope: array.Scope,
ContainerType: array.Type,
}

fmt.Printf("*** make: => %v\n", ptr)

return ptr, true, nil
return v, true, nil
}

typeInfo.Bits = length
Expand Down

0 comments on commit be3e504

Please sign in to comment.