コード例 #1
0
        public Value CreateAttributeSingleton(AttributeType type)
        {
            if (type.Members.Count != 0)
            {
                throw new CompilerBugException();
            }

            var name = "singleton_" + type.GetMangledName();
            var attr = LlvmModule.GetNamedGlobal(name);

            if (attr != null)
            {
                goto Ret;
            }

            attr             = LlvmModule.AddGlobal(type, name);
            attr.Initializer = LLVMValueRef.CreateConstNamedStruct(type, ReadOnlySpan <LLVMValueRef> .Empty);

Ret:
            return(new Value
            {
                Type = type,
                LlvmValue = attr,
            });
        }