示例#1
0
func (v *AttributeCheck) CheckStructType(s *SemanticAnalyzer, n ast.StructType) {
	for _, attr := range n.Attrs() {
		switch attr.Key {
		case "packed":
			if attr.Value != "" {
				s.Err(attr, "Struct attribute `%s` doesn't expect value", attr.Key)
			}
		case "deprecated":
			// value is optional, nothing to check
		default:
			s.Err(attr, "Invalid struct attribute key `%s`", attr.Key)
		}
	}
}
示例#2
0
文件: type.go 项目: kiljacken/ark
func (v *Codegen) addStructType(typ ast.StructType, name string, gcon *ast.GenericContext) {
	if _, ok := v.namedTypeLookup[name]; ok {
		return
	}

	structure := v.curFile.LlvmModule.Context().StructCreateNamed(name)

	v.namedTypeLookup[name] = structure

	for _, field := range typ.Members {
		if _, ok := field.Type.BaseType.(*ast.NamedType); ok {
			v.addNamedTypeReference(field.Type, gcon)
		}
	}

	structure.StructSetBody(v.structTypeToLLVMTypeFields(typ, gcon), typ.Attrs().Contains("packed"))
}
示例#3
0
文件: type.go 项目: kiljacken/ark
func (v *Codegen) structTypeToLLVMType(typ ast.StructType, gcon *ast.GenericContext) llvm.Type {
	return llvm.StructType(v.structTypeToLLVMTypeFields(typ, gcon), typ.Attrs().Contains("packed"))
}