| 841 | } |
| 842 | |
| 843 | ExternComponentCodeGenInfo CLikeCodeGen::ExtractExternComponentInfo(const ILObjectDefinition & input) |
| 844 | { |
| 845 | auto type = input.Type.Ptr(); |
| 846 | auto recType = ExtractRecordType(type); |
| 847 | ExternComponentCodeGenInfo info; |
| 848 | info.Type = type; |
| 849 | Token bindingVal; |
| 850 | if (input.Attributes.TryGetValue("Binding", bindingVal)) |
| 851 | info.Binding = StringToInt(bindingVal.Content); |
| 852 | if (recType) |
| 853 | { |
| 854 | if (auto genType = dynamic_cast<ILGenericType*>(type)) |
| 855 | { |
| 856 | if (genType->GenericTypeName == "Patch") |
| 857 | { |
| 858 | type = genType->BaseType.Ptr(); |
| 859 | info.DataStructure = ExternComponentCodeGenInfo::DataStructureType::Patch; |
| 860 | } |
| 861 | } |
| 862 | if (auto arrType = dynamic_cast<ILArrayType*>(type)) |
| 863 | { |
| 864 | if (info.DataStructure != ExternComponentCodeGenInfo::DataStructureType::StandardInput && |
| 865 | info.DataStructure != ExternComponentCodeGenInfo::DataStructureType::Patch) |
| 866 | { |
| 867 | errWriter->diagnose(input.Position, Diagnostics::cannotGenerateCodeForExternComponentType, type); |
| 868 | } |
| 869 | type = arrType->BaseType.Ptr(); |
| 870 | info.IsArray = true; |
| 871 | info.ArrayLength = arrType->ArrayLength; |
| 872 | } |
| 873 | if (type != recType) |
| 874 | { |
| 875 | errWriter->diagnose(input.Position, Diagnostics::cannotGenerateCodeForExternComponentType, type); |
| 876 | } |
| 877 | } |
| 878 | else |
| 879 | { |
| 880 | // check for attributes |
| 881 | if (input.Attributes.ContainsKey("TessCoord")) |
| 882 | { |
| 883 | info.SystemVar = ExternComponentCodeGenInfo::SystemVarType::TessCoord; |
| 884 | if (!(input.Type->IsFloatVector() && input.Type->GetVectorSize() <= 3)) |
| 885 | getSink()->diagnose(input.Position, Diagnostics::invalidTessCoordType); |
| 886 | } |
| 887 | else if (input.Attributes.ContainsKey("FragCoord")) |
| 888 | { |
| 889 | info.SystemVar = ExternComponentCodeGenInfo::SystemVarType::FragCoord; |
| 890 | if (!(input.Type->IsFloatVector() && input.Type->GetVectorSize() == 4)) |
| 891 | getSink()->diagnose(input.Position, Diagnostics::invalidFragCoordType); |
| 892 | } |
| 893 | else if (input.Attributes.ContainsKey("InvocationId")) |
| 894 | { |
| 895 | info.SystemVar = ExternComponentCodeGenInfo::SystemVarType::InvocationId; |
| 896 | if (!input.Type->IsInt()) |
| 897 | getSink()->diagnose(input.Position, Diagnostics::invalidInvocationIdType); |
| 898 | } |
| 899 | else if (input.Attributes.ContainsKey("ThreadId")) |
| 900 | { |
nothing calls this directly
no test coverage detected