Changeset 3857 for devel-tools
- Timestamp:
- Jul 21, 2008, 5:27:15 PM (13 years ago)
- Location:
- devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/compiler
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/compiler/ExprChecker.java
r3856 r3857 1 1 package org.refal.rfpdt.compiler; 2 3 import java.util.HashSet; 2 4 3 5 import org.refal.rfpdt.ast.AstAlt; … … 54 56 } 55 57 56 private final class ConstChecker implements ExprVisitorWithEnv<Container WithVar> {57 public void visit (AstCall astCall, Container WithVare) {58 private final class ConstChecker implements ExprVisitorWithEnv<Container> { 59 public void visit (AstCall astCall, Container e) { 58 60 msgHandler.send(astCall.pos, MsgCode.UnexpectedFunctionCallInConst); 59 61 e.noError = false; 60 62 } 61 63 62 public void visit (AstCharSymbol astCharSymbol, Container WithVare) {}63 64 public void visit (AstExpr astExpr, Container WithVare) {65 Container WithVar e1 = new ContainerWithVar();64 public void visit (AstCharSymbol astCharSymbol, Container e) {} 65 66 public void visit (AstExpr astExpr, Container e) { 67 Container e1 = new Container(); 66 68 for (AstTerm astTerm : astExpr.termList) 67 69 astTerm.accept(this, e1); … … 69 71 } 70 72 71 public void visit (AstNumberSymbol astNumberSymbol, Container WithVare) {}72 73 public void visit (AstParen astParen, Container WithVare) {73 public void visit (AstNumberSymbol astNumberSymbol, Container e) {} 74 75 public void visit (AstParen astParen, Container e) { 74 76 astParen.expr.accept(this, e); 75 77 } 76 78 77 public void visit (AstRef astRef, Container WithVare) {79 public void visit (AstRef astRef, Container e) { 78 80 if (astRef.decl == null) 79 81 e.noError = false; 80 else if (astRef.decl instanceof AstConstBinding && !((AstConstBinding) astRef.decl).expr.noError) { 81 msgHandler.send(astRef.name.pos, MsgCode.UncheckedConstInConst); 82 e.noError = false; 82 else if (astRef.decl instanceof AstConstBinding) { 83 AstConstBinding astConstBinding = (AstConstBinding) astRef.decl; 84 if (stackConstBinding.contains(astConstBinding)) { 85 msgHandler.send(astRef.name.pos, MsgCode.RecursiveDefinitionInConst); 86 e.noError = false; 87 } else { 88 checkAstConstBinding(astConstBinding); 89 e.noError &= astConstBinding.expr.noError; 90 } 83 91 } 84 92 } 85 93 86 public void visit (AstVar astVar, Container WithVare) {94 public void visit (AstVar astVar, Container e) { 87 95 msgHandler.send(astVar.pos, MsgCode.UnexpectedVariableInConst); 88 96 e.noError = false; 89 97 } 90 98 91 public void visit (AstWordSymbol astWordSymbol, Container WithVare) {}99 public void visit (AstWordSymbol astWordSymbol, Container e) {} 92 100 } 93 101 … … 194 202 195 203 private final MsgHandler msgHandler; 204 205 private final HashSet<AstConstBinding> checkedConstBinding; 206 private HashSet<AstConstBinding> stackConstBinding; 196 207 197 208 private ExprChecker (final MsgHandler msgHandler) { 198 209 this.msgHandler = msgHandler; 199 } 200 201 private void checkConst (AstExpr astExpr) { 202 ContainerWithVar e = new ContainerWithVar(); 210 this.checkedConstBinding = new HashSet<AstConstBinding>(); 211 } 212 213 private void checkAstConstBinding (AstConstBinding astConstBinding) { 214 if (checkedConstBinding.contains(astConstBinding)) 215 return; 216 stackConstBinding.add(astConstBinding); 217 AstExpr astExpr = astConstBinding.expr; 218 Container e = new Container(); 203 219 astExpr.accept(new ConstChecker(), e); 204 220 astExpr.noError = e.noError; 221 checkedConstBinding.add(astConstBinding); 205 222 } 206 223 … … 226 243 227 244 public void visit (AstConstBinding astConstBinding) { 228 checkConst(astConstBinding.expr); 245 stackConstBinding = new HashSet<AstConstBinding>(); 246 checkAstConstBinding(astConstBinding); 229 247 } 230 248 -
devel-tools/trunk/eclipse/org.refal.rfpdt.core/src/org/refal/rfpdt/compiler/MsgCode.java
r3856 r3857 43 43 TwoOccurrencesOfTheVariable_X_HaveDifferentTypes(Severity.Error, 44 44 "Two occurrences of the variable %s have different types"), // 45 UncheckedConstInConst(Severity.Error, "Unchecked constant reference inconstant expression"), //45 RecursiveDefinitionInConst(Severity.Error, "Recursive definition of constant expression"), // 46 46 UnexpectedEndOfComment(Severity.Error, "Unexpected end of comment"), // 47 47 UnexpectedEndOfWord(Severity.Error, "Word literal is not properly closed by a double-quote"), //
Note: See TracChangeset
for help on using the changeset viewer.