001 /* Copyright 2000, 2001, Compaq Computer Corporation */
002
003 package escjava.translate;
004
005 import javafe.util.Assert;
006 import javafe.util.Set;
007 import javafe.util.ErrorSet;
008 import javafe.ast.*;
009
010 import escjava.ast.*;
011 import escjava.ast.TagConstants;
012
013
014
015 public class Helper {
016
017 /** Provides support for appropriately handling the 'helper' pragma
018 during translation.
019 **/
020
021 /* The following decoration lets us cache the fact that a given
022 RoutineDecl is known to be not helper recursive, so that we don't
023 have to recompute this fact. In particular, the helperDecoration of
024 a RoutineDecl is non-null precisely when the RoutineDecl is known
025 to be not helper recursive.
026
027 FIXME - this is not currently used, but should be?
028
029 static {
030 ASTDecoration helperDecoration =
031 new ASTDecoration("helperDecoration");
032 }
033 */
034
035
036 /* Returns true iff the given RoutineDecl has a 'helper' modifier
037 pragma.
038 */
039 public static boolean isHelper(RoutineDecl r) {
040 if (r != null && r.pmodifiers != null) {
041 int pmodSize = r.pmodifiers.size();
042 for (int i = 0; i < pmodSize; i++) {
043 ModifierPragma mp = r.pmodifiers.elementAt(i);
044 if (mp.getTag() == TagConstants.HELPER) {
045 return true;
046 }
047 }
048 }
049 return false;
050 }
051
052
053 // Abort the program because the given RoutineDecl is helper recursive.
054 public static void abort(/*@ non_null */ RoutineDecl rd) {
055 ErrorSet.fatal(rd.locId, "helper routine is recursive");
056 }
057
058 }