作者:minu
项目:llg
func (m *TypeMap) descriptorSlice(t *types.Slice, name string) TypeDebugDescriptor {
sliceStruct := types.NewStruct([]*types.Var{
types.NewVar(0, nil, "ptr", types.NewPointer(t.Elem())),
types.NewVar(0, nil, "len", types.Typ[types.Int]),
types.NewVar(0, nil, "cap", types.Typ[types.Int]),
}, nil)
return m.typeDebugDescriptor(sliceStruct, name)
}
作者:hzmange
项目:llg
func (tm *TypeMap) sliceRuntimeType(s *types.Slice) (global, ptr llvm.Value) {
rtype := tm.makeRtype(s, reflect.Slice)
elemRuntimeType := tm.ToRuntime(s.Elem())
sliceType := llvm.ConstNull(tm.runtimeSliceType)
sliceType = llvm.ConstInsertValue(sliceType, rtype, []uint32{0})
sliceType = llvm.ConstInsertValue(sliceType, elemRuntimeType, []uint32{1})
return tm.makeRuntimeTypeGlobal(sliceType)
}
作者:quarnste
项目:llg
func (tm *TypeMap) sliceRuntimeType(tstr string, s *types.Slice) (global, ptr llvm.Value) {
rtype := tm.makeRtype(s, reflect.Slice)
sliceType := llvm.ConstNull(tm.runtimeSliceType)
global, ptr = tm.makeRuntimeTypeGlobal(sliceType)
sliceType = llvm.ConstInsertValue(sliceType, rtype, []uint32{0})
elemRuntimeType := tm.ToRuntime(s.Elem())
sliceType = llvm.ConstInsertValue(sliceType, elemRuntimeType, []uint32{1})
global.SetInitializer(sliceType)
return global, ptr
}
作者:minu
项目:llg
func (tm *llvmTypeMap) sliceLLVMType(s *types.Slice, name string) llvm.Type {
typ, ok := tm.types.At(s).(llvm.Type)
if !ok {
typ = llvm.GlobalContext().StructCreateNamed(name)
tm.types.Set(s, typ)
elements := []llvm.Type{
llvm.PointerType(tm.ToLLVM(s.Elem()), 0),
tm.inttype,
tm.inttype,
}
typ.StructSetBody(elements, false)
}
return typ
}
作者:hzmange
项目:llg
func (tm *LLVMTypeMap) sliceLLVMType(tstr string, s *types.Slice) llvm.Type {
typ, ok := tm.types[tstr]
if !ok {
typ = llvm.GlobalContext().StructCreateNamed("")
tm.types[tstr] = typ
elements := []llvm.Type{
llvm.PointerType(tm.ToLLVM(s.Elem()), 0),
tm.inttype,
tm.inttype,
}
typ.StructSetBody(elements, false)
}
return typ
}