public Type lookupType(String name) { ScopeEntry entry = lookupScopeEntry(name); if (entry == null) { return null; } return entry.getType(); }
@Override public void visitBlockStmt(BlockStmt stmt) { if (stmt == blockOfInterest) { inBlock = true; possiblyShadowedScopeEntry = currentScope.lookupScopeEntry(nameOfInterest); } super.visitBlockStmt(stmt); if (stmt == blockOfInterest) { inBlock = false; possiblyShadowedScopeEntry = null; } }
private boolean isCurrentComponentVariable(String name) { ScopeEntry entry = currentScope.lookupScopeEntry(name); return entry != null && entry.hasVariableDeclInfo() && currentComponent.getVariableDeclInfo() == entry.getVariableDeclInfo(); }
@Override public void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr) { super.visitVariableIdentifierExpr(variableIdentifierExpr); final ScopeEntry se = currentScope.lookupScopeEntry(variableIdentifierExpr.getName()); if (se != null && se.hasVariableDeclInfo() && se.getVariableDeclInfo() == backupVdi) { found = true; } }
@Override public void visitVariableIdentifierExpr(VariableIdentifierExpr variableIdentifierExpr) { super.visitVariableIdentifierExpr(variableIdentifierExpr); if (inBlock && possiblyShadowedScopeEntry != null && currentScope.lookupScopeEntry(variableIdentifierExpr.getName()) == possiblyShadowedScopeEntry) { ok = false; } }
@Override public void visit(IAstNode node) { if (node == donorFragment) { assert structDefinitionTypes.isEmpty(); for (String structName : currentScope.namesOfAllStructDefinitionsInScope()) { structDefinitionTypes.add(currentScope.lookupStructName(structName)); } } super.visit(node); }
private boolean isScopeEntryForVectorVariable(ScopeEntry scopeEntry) { return scopeEntry != null && scopeEntry.hasVariableDeclInfo() && scopeEntry.getVariableDeclInfo() == vectorVariableDeclInfo; }
private static boolean canTypeCheckWithoutFailure(TranslationUnit reference, ShadingLanguageVersion shadingLanguageVersion) { // Debugging aid: fail early if we end up messing up the translation unit so that type checking // does not work. new Typer(reference, shadingLanguageVersion); return true; }
@Override public void visitFunctionDefinition(FunctionDefinition functionDefinition) { currentFunction = functionDefinition; super.visitFunctionDefinition(functionDefinition); currentFunction = null; }
@Override protected void leaveBlockStmt(BlockStmt stmt) { lastExitedBlock = stmt; super.leaveBlockStmt(stmt); }
InjectionPoint(FunctionDefinition enclosingFunction, boolean inLoop, Scope scope) { this.enclosingFunction = enclosingFunction; this.inLoop = inLoop; this.scope = scope.shallowClone(); }
@Override public void visitArrayIndexExpr(ArrayIndexExpr arrayIndexExpr) { arrayIndexDepth++; super.visitArrayIndexExpr(arrayIndexExpr); arrayIndexDepth--; }
public void add(String name, Type type, Optional<ParameterDecl> parameterDecl, VariableDeclInfo declInfo, VariablesDeclaration variablesDecl) { checkNameTypeAndParam(name, type, parameterDecl); variableMapping.put(name, new ScopeEntry(type, parameterDecl, declInfo, variablesDecl)); }
@Override public void visitScalarInitializer(ScalarInitializer scalarInitializer) { assert !inInitializer; inInitializer = true; super.visitScalarInitializer(scalarInitializer); inInitializer = false; }
@Override public void visitArrayInitializer(ArrayInitializer arrayInitializer) { assert !inInitializer; inInitializer = true; super.visitArrayInitializer(arrayInitializer); inInitializer = false; }
@Override public void visitFunctionDefinition(FunctionDefinition functionDefinition) { assert atGlobalScope; atGlobalScope = false; super.visitFunctionDefinition(functionDefinition); assert !atGlobalScope; atGlobalScope = true; }
@Override public void visitFunctionDefinition(FunctionDefinition functionDefinition) { assert atGlobalScope; atGlobalScope = false; super.visitFunctionDefinition(functionDefinition); atGlobalScope = true; }