| 1728 | return expr; |
| 1729 | } |
| 1730 | virtual RefPtr<ExpressionSyntaxNode> VisitVarExpression(VarExpressionSyntaxNode *expr) override |
| 1731 | { |
| 1732 | ShaderUsing shaderObj; |
| 1733 | expr->Type = ExpressionType::Error; |
| 1734 | auto decl = expr->Scope->LookUp(expr->Variable); |
| 1735 | auto varDecl = dynamic_cast<VarDeclBase*>(decl); |
| 1736 | if (varDecl) |
| 1737 | { |
| 1738 | expr->Type = varDecl->Type; |
| 1739 | if (auto basicType = expr->Type->AsBasicType()) |
| 1740 | basicType->IsLeftValue = !(dynamic_cast<ComponentSyntaxNode*>(varDecl)); |
| 1741 | } |
| 1742 | else if (currentShader && currentShader->ShaderObjects.TryGetValue(expr->Variable, shaderObj)) |
| 1743 | { |
| 1744 | auto basicType = new BasicExpressionType(BaseType::Shader); |
| 1745 | basicType->Shader = shaderObj.Shader; |
| 1746 | basicType->IsLeftValue = false; |
| 1747 | expr->Type = basicType; |
| 1748 | } |
| 1749 | else if (currentPipeline && currentImportOperator) |
| 1750 | { |
| 1751 | RefPtr<ShaderComponentSymbol> comp; |
| 1752 | if (currentPipeline->Components.TryGetValue(expr->Variable, comp)) |
| 1753 | { |
| 1754 | currentImportOperator->Usings.Add(comp->Name); |
| 1755 | expr->Type = comp->Type->DataType; |
| 1756 | } |
| 1757 | else |
| 1758 | getSink()->diagnose(expr, Diagnostics::undefinedIdentifier2, expr->Variable); |
| 1759 | } |
| 1760 | else if (currentShader) |
| 1761 | { |
| 1762 | auto compRef = currentShader->ResolveComponentReference(expr->Variable); |
| 1763 | if (compRef.IsAccessible) |
| 1764 | { |
| 1765 | expr->Type = compRef.Component->Type->DataType->Clone(); |
| 1766 | if (auto basicType = expr->Type->AsBasicType()) |
| 1767 | basicType->IsLeftValue = false; |
| 1768 | } |
| 1769 | else if (compRef.Component) |
| 1770 | { |
| 1771 | getSink()->diagnose(expr, Diagnostics::componentNotAccessibleFromShader, expr->Variable, currentShader->SyntaxNode->Name); |
| 1772 | } |
| 1773 | else |
| 1774 | getSink()->diagnose(expr, Diagnostics::undefinedIdentifier2, expr->Variable); |
| 1775 | } |
| 1776 | else if (auto compDecl = dynamic_cast<ComponentSyntaxNode*>(decl)) // interface decl |
| 1777 | { |
| 1778 | expr->Type = compDecl->Type; |
| 1779 | if (auto basicType = expr->Type->AsBasicType()) |
| 1780 | basicType->IsLeftValue = false; |
| 1781 | } |
| 1782 | else |
| 1783 | getSink()->diagnose(expr, Diagnostics::undefinedIdentifier2, expr->Variable); |
| 1784 | |
| 1785 | if (expr->Type->IsGenericType("Uniform") || expr->Type->IsGenericType("Patch") || expr->Type->IsGenericType("StorageBuffer")) |
| 1786 | expr->Type = expr->Type->AsGenericType()->BaseType; |
| 1787 |
nothing calls this directly
no test coverage detected