Exemplo n.º 1
0
func (v *Codegen) structTypeToLLVMType(typ *parser.StructType) llvm.Type {
	if t, ok := v.structLookup_UseHelperFunction[typ]; ok {
		return t
	}

	return llvm.StructType(v.structTypeToLLVMTypeFields(typ), typ.Attrs().Contains("packed"))
}
Exemplo n.º 2
0
func (v *AttributeCheck) CheckStructType(s *SemanticAnalyzer, n parser.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)
		}
	}
}
Exemplo n.º 3
0
Arquivo: codegen.go Projeto: vnev/ark
func (v *Codegen) addStructType(typ parser.StructType, name string) {
	if _, ok := v.namedTypeLookup[name]; ok {
		return
	}

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

	v.namedTypeLookup[name] = structure

	for _, field := range typ.Variables {
		if named, ok := field.Variable.Type.(*parser.NamedType); ok {
			v.addNamedType(named)
		}
	}

	structure.StructSetBody(v.structTypeToLLVMTypeFields(typ), typ.Attrs().Contains("packed"))
}
Exemplo n.º 4
0
Arquivo: type.go Projeto: vnev/ark
func (v *Codegen) structTypeToLLVMType(typ parser.StructType) llvm.Type {
	return llvm.StructType(v.structTypeToLLVMTypeFields(typ), typ.Attrs().Contains("packed"))
}