Пример #1
0
func (v *Codegen) addNamedTypeReference(n *ast.TypeReference, gcon *ast.GenericContext) {
	outer := gcon
	gcon = ast.NewGenericContextFromTypeReference(n)
	gcon.Outer = outer

	v.addNamedType(n.BaseType.(*ast.NamedType), ast.TypeReferenceMangledName(ast.MANGLE_ARK_UNSTABLE, n, gcon), gcon)
}
Пример #2
0
// if outer is not nil, this function does not add the current function gcon as outer, as it assumes it is already there
func (v *Codegen) typeRefToLLVMTypeWithOuter(typ *ast.TypeReference, outer *ast.GenericContext) llvm.Type {
	var gcon *ast.GenericContext
	if len(typ.GenericArguments) > 0 {
		gcon = ast.NewGenericContextFromTypeReference(typ)
	} else {
		gcon = ast.NewGenericContext(nil, nil)
	}

	if outer != nil {
		gcon.Outer = outer
	} else if v.inFunction() {
		gcon.Outer = v.currentFunction().gcon
	}

	return v.typeRefToLLVMTypeWithGenericContext(typ, gcon)
}