Example #1
0
    llvm::GlobalVariable *Property::GetMemberInfo()
    {
        if(!propertyInfo)
        {
            // Only create the property info variable when reflection is enabled.
            Module *module = GetModule();
            if(!module->HasReflection())
                return NULL;

            // Get the property info class.
            VirtualMachine *vm = module->GetVirtualMachine();
            Class *propInfoClass = vm->GetPropertyInfoClass();
            llvm::Module *targetModule = module->GetTargetModule();
            propertyInfo = new llvm::GlobalVariable(*targetModule, propInfoClass->GetTargetType(),
                                    false, ComputeMetadataLinkage(), NULL, GetMangledName() + "_propinfo_");
        }

        return propertyInfo;
    }
Example #2
0
    void Property::DefinitionPass()
    {
        // Only create once the member info.
        if(createdMemberInfo)
            return;
        createdMemberInfo = true;

        // Only create the reflection info in modules that support it.    
        Module *module = GetModule();
        if(!module->HasReflection())
            return;

        // Get the property info class.
        VirtualMachine *vm = module->GetVirtualMachine();
        Class *propInfoClass = vm->GetPropertyInfoClass();

        // Create the property info value.
        ConstantStructurePtr propInfoValue(propInfoClass->CreateConstant(module));

        // Store the MemberInfo attributes.
        SetMemberInfoData(propInfoValue);

        // Set the "getMethod" field.
        if(getAccessor)
            propInfoValue->SetField("getMethod", getAccessor->GetMemberInfo());

        // Set the "setMethod" field.
        if(setAccessor)
            propInfoValue->SetField("setMethod", setAccessor->GetMemberInfo());

        // Set the property type field.
        propInfoValue->SetField("propertyType", GetReflectedType(GetType()));

        // Set the field info.
        GetMemberInfo()->setInitializer(propInfoValue->Finish());

        // Define the custom attributes.
        DefineAttributes();
    }