From 91a7d8455f4c9bb05f8e06f26af62748435620e8 Mon Sep 17 00:00:00 2001 From: Dave Parker Date: Wed, 2 Apr 2008 10:57:25 +0000 Subject: [PATCH] Added fallback type computation to getType(). git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@718 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/src/parser/ast/ASTElement.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/prism/src/parser/ast/ASTElement.java b/prism/src/parser/ast/ASTElement.java index a41ff697..7303efb6 100644 --- a/prism/src/parser/ast/ASTElement.java +++ b/prism/src/parser/ast/ASTElement.java @@ -108,8 +108,22 @@ public abstract class ASTElement // Get methods + /** + * Get the type for this element. It should have already been computed + * by calling typeCheck(). If not, it will be computed first but, in + * the case of error, you will get "unknown" type, not the error. + */ public int getType() { + if (type != 0) return type; + try { + typeCheck(); + } + catch (PrismLangException e) { + // Returns 0 (unknown) in case of error. + // If you want to check for errors, use typeCheck(). + return 0; + } return type; }