Exemple #1
0
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)
}
Exemple #2
0
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)
}
Exemple #3
0
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
}
Exemple #4
0
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
}
Exemple #5
0
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
}