@Override public void visitFunctionDefinition(FunctionDefinition functionDefinition) { assert enclosingFunction == null; enclosingFunction = functionDefinition; pushScope(); addEncounteredParametersToScope = true; visitFunctionPrototype(functionDefinition.getPrototype()); addEncounteredParametersToScope = false; visit(functionDefinition.getBody()); popScope(); enclosingFunction = null; }
@Override public void visitVariablesDeclaration(VariablesDeclaration variablesDeclaration) { visit(variablesDeclaration.getBaseType()); List<VariableDeclInfo> children = new ArrayList<>(); children.addAll(variablesDeclaration.getDeclInfos()); for (VariableDeclInfo declInfo : children) { visitVariableDeclInfo(declInfo); currentScope.add(declInfo.getName(), declInfo.getArrayInfo() == null ? variablesDeclaration.getBaseType() : new ArrayType(variablesDeclaration.getBaseType(), declInfo.getArrayInfo()), Optional.empty(), declInfo, variablesDeclaration); visitVariableDeclInfoAfterAddedToScope(declInfo); } }
@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); }
/** * Because WebGL places limits on for loops it can be convenient to only visit the body of a * for loop, skipping the header. Subclasses can call this method to invoke this behaviour * during visitation, instead of calling super.visitForStmt(...). * * @param forStmt For statement whose body should be visited */ protected void visitForStmtBodyOnly(ForStmt forStmt) { pushScope(); visit(forStmt.getBody()); popScope(); }