예제 #1
0
 /**
  * Add the given permission to the permission set.
  *
  * @param permissions The permission set
  * @param toAdd The permissions to add
  * @return The same permission set as passed in
  */
 private static EnumSet<Permission> addPermission(
     EnumSet<Permission> permissions, Permission... toAdd) {
   for (Permission onePerm : toAdd) {
     // Permissions that infer other permissions need to be listed here and
     // set the inferred permissions as well as itself.
     //
     // Always add the permission itself and then call this method to add
     // the inferred permissions.
     switch (onePerm) {
       case ADMIN:
         permissions.addAll(EnumSet.allOf(Permission.class));
         break;
       case SQL:
         permissions.add(SQL);
         addPermission(permissions, SQLREAD, DEFAULTPROC);
         break;
       case SQLREAD:
         permissions.add(SQLREAD);
         addPermission(permissions, DEFAULTPROCREAD);
         break;
       case DEFAULTPROC:
         permissions.add(DEFAULTPROC);
         addPermission(permissions, DEFAULTPROCREAD);
       default:
         permissions.add(onePerm);
     }
   }
   return permissions;
 }
예제 #2
0
 @Override
 public Set<ForgeDirection> getAllConnections() {
   EnumSet<ForgeDirection> result = EnumSet.noneOf(ForgeDirection.class);
   for (IConduit con : conduits) {
     result.addAll(con.getConduitConnections());
   }
   return result;
 }
  /**
   * Redraws the sources on this layer, after first refreshing them based on the current state of
   * the {@link com.google.android.stardroid.control.AstronomerModel}.
   */
  protected synchronized void refreshSources(EnumSet<UpdateType> updateTypes) {
    for (AstronomicalSource astroSource : astroSources) {
      updateTypes.addAll(astroSource.update());
    }

    if (!updateTypes.isEmpty()) {
      redraw(updateTypes);
    }
  }
예제 #4
0
 @Override
 public EnumSet<ForgeDirection> getConnections() {
   EnumSet<ForgeDirection> cons = EnumSet.noneOf(ForgeDirection.class);
   cons.addAll(getConduitConnections());
   for (ForgeDirection dir : getExternalConnections()) {
     if (getConnectionMode(dir) != ConnectionMode.DISABLED) {
       cons.add(dir);
     }
   }
   return cons;
 }
  private static void putType(final EnumSet<NodeType> types, final String s) {
    if (ANY.equals(s)) {
      types.addAll(EnumSet.allOf(NodeType.class));
      return;
    }

    final NodeType type = NodeType.fromName(s);
    types.add(type);

    if (type == NodeType.NUMBER) types.add(NodeType.INTEGER);
  }
예제 #6
0
  public static Set<Make> makeWithDpendencies(Make... makes) {

    EnumSet<Make> makeSet = EnumSet.noneOf(Make.class);

    makeSet.addAll(
        Arrays.asList(makes)
            .stream()
            .flatMap(m -> Stream.concat(dependencies.apply(m), Stream.of(m)))
            .collect(Collectors.toList()));

    return Collections.unmodifiableSet(makeSet);
  }
  public EnrollmentDialog(
      Frame owner,
      int maxCount,
      final String reasonToFail,
      EnumMap<DPFPFingerIndex, DPFPTemplate> templates) {
    super(owner, true);
    this.templates = templates;

    setTitle("Fingerprint Enrollment");

    DPFPEnrollmentControl enrollmentControl = new DPFPEnrollmentControl();

    EnumSet<DPFPFingerIndex> fingers = EnumSet.noneOf(DPFPFingerIndex.class);
    fingers.addAll(templates.keySet());
    enrollmentControl.setEnrolledFingers(fingers);
    enrollmentControl.setMaxEnrollFingerCount(maxCount);

    enrollmentControl.addEnrollmentListener(
        new DPFPEnrollmentListener() {
          public void fingerDeleted(DPFPEnrollmentEvent e) throws DPFPEnrollmentVetoException {
            if (reasonToFail != null) {
              throw new DPFPEnrollmentVetoException(reasonToFail);
            } else {
              EnrollmentDialog.this.templates.remove(e.getFingerIndex());
            }
          }

          public void fingerEnrolled(DPFPEnrollmentEvent e) throws DPFPEnrollmentVetoException {
            if (reasonToFail != null) {
              //                  e.setStopCapture(false);
              throw new DPFPEnrollmentVetoException(reasonToFail);
            } else EnrollmentDialog.this.templates.put(e.getFingerIndex(), e.getTemplate());
          }
        });

    getContentPane().setLayout(new BorderLayout());

    JButton closeButton = new JButton("Close");
    closeButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            setVisible(false); // End Dialog
          }
        });

    JPanel bottom = new JPanel();
    bottom.add(closeButton);
    add(enrollmentControl, BorderLayout.CENTER);
    add(bottom, BorderLayout.PAGE_END);

    pack();
    setLocationRelativeTo(null);
  }
 public MutableExecutionLog(ExecutionLog copyFrom) {
   _logMode = ExecutionLogMode.FULL;
   _logLevels.addAll(copyFrom.getLogLevels());
   if (copyFrom.getEvents() != null) {
     _events = new LinkedList<LogEvent>(copyFrom.getEvents());
   } else {
     _events = new LinkedList<LogEvent>();
   }
   _exceptionClass = copyFrom.getExceptionClass();
   _exceptionMessage = copyFrom.getExceptionMessage();
   _exceptionStackTrace = copyFrom.getExceptionStackTrace();
 }
예제 #9
0
파일: MapView.java 프로젝트: H-Theking/josm
  /**
   * Add a layer to the current MapView. The layer will be added at topmost position.
   *
   * @param layer The layer to add
   */
  public void addLayer(Layer layer) {
    boolean isOsmDataLayer = layer instanceof OsmDataLayer;
    layerLock.writeLock().lock();
    layerLock.readLock().lock();
    EnumSet<LayerListenerType> listenersToFire = EnumSet.noneOf(LayerListenerType.class);
    Layer oldActiveLayer = activeLayer;
    OsmDataLayer oldEditLayer = editLayer;
    try {
      try {
        if (layer instanceof MarkerLayer && playHeadMarker == null) {
          playHeadMarker = PlayHeadMarker.create();
        }

        if (layer instanceof GpxLayer) {
          addGpxLayer((GpxLayer) layer);
        } else if (layers.isEmpty()) {
          layers.add(layer);
        } else if (layer.isBackgroundLayer()) {
          int i = 0;
          for (; i < layers.size(); i++) {
            if (layers.get(i).isBackgroundLayer()) {
              break;
            }
          }
          layers.add(i, layer);
        } else {
          layers.add(0, layer);
        }

        if (isOsmDataLayer || oldActiveLayer == null) {
          // autoselect the new layer
          listenersToFire.addAll(setActiveLayer(layer, true));
        }
      } finally {
        layerLock.writeLock().unlock();
      }

      fireLayerAdded(layer);
      if (isOsmDataLayer) {
        ((OsmDataLayer) layer).addLayerStateChangeListener(this);
      }
      onActiveEditLayerChanged(oldActiveLayer, oldEditLayer, listenersToFire);
      layer.addPropertyChangeListener(this);
      Main.addProjectionChangeListener(layer);
      AudioPlayer.reset();
    } finally {
      layerLock.readLock().unlock();
    }
    if (!listenersToFire.isEmpty()) {
      repaint();
    }
  }
예제 #10
0
 private void resetFocus() {
   recycleViews();
   removeAllViewsInLayout();
   mLazyInit.addAll(EnumSet.allOf(LazyInit.class));
   for (int i = Math.max(0, mCurrentAdapterIndex - mBufferedItemCount);
       i < Math.min(mAdapter.getCount(), mCurrentAdapterIndex + mBufferedItemCount + 1);
       i++) {
     mLoadedViews.addLast(makeAndAddView(i, true));
     if (i == mCurrentAdapterIndex) {
       mCurrentBufferIndex = mLoadedViews.size() - 1;
     }
   }
   requestLayout();
 }
예제 #11
0
 private EnumSet<ActMood> getImpliedConcepts() {
   if (_impliedConcepts == null) {
     if (_parent == null) { // then _parent2, 3 is also null
       _impliedConcepts = EnumSet.of(root);
       _impliedConcepts.add(this);
     } else {
       _impliedConcepts = EnumSet.copyOf(_parent.getImpliedConcepts());
       _impliedConcepts.add(this);
       if (_parent2 != null) _impliedConcepts.addAll(_parent2.getImpliedConcepts());
       if (_parent3 != null) _impliedConcepts.addAll(_parent3.getImpliedConcepts());
     }
   }
   return _impliedConcepts;
 }
예제 #12
0
파일: MapView.java 프로젝트: H-Theking/josm
  /**
   * Sets the active layer. Propagates this change to all map buttons.
   *
   * @param layer The layer to be active.
   * @param setEditLayer if this is <code>true</code>, the edit layer is also set.
   * @return A list of change listeners that should be fired using {@link
   *     #onActiveEditLayerChanged(Layer, OsmDataLayer, EnumSet)}
   */
  private EnumSet<LayerListenerType> setActiveLayer(final Layer layer, boolean setEditLayer) {
    if (layer != null && !layers.contains(layer))
      throw new IllegalArgumentException(
          tr("Layer ''{0}'' must be in list of layers", layer.toString()));

    if (layer == activeLayer) return EnumSet.noneOf(LayerListenerType.class);

    activeLayer = layer;
    EnumSet<LayerListenerType> listenersToFire = EnumSet.of(LayerListenerType.ACTIVE_LAYER_CHANGE);
    if (setEditLayer) {
      listenersToFire.addAll(setEditLayer(layers));
    }

    return listenersToFire;
  }
예제 #13
0
파일: MapView.java 프로젝트: H-Theking/josm
  /**
   * Remove the layer from the mapview. If the layer was in the list before, an LayerChange event is
   * fired.
   *
   * @param layer The layer to remove
   */
  public void removeLayer(Layer layer) {
    layerLock.writeLock().lock();
    layerLock.readLock().lock();

    EnumSet<LayerListenerType> listenersToFire = EnumSet.noneOf(LayerListenerType.class);
    Layer oldActiveLayer = activeLayer;
    OsmDataLayer oldEditLayer = editLayer;
    try {
      try {
        List<Layer> layersList = new ArrayList<>(layers);

        if (!layersList.remove(layer)) return;

        listenersToFire = setEditLayer(layersList);

        if (layer == activeLayer) {
          listenersToFire.addAll(setActiveLayer(determineNextActiveLayer(layersList), false));
        }

        if (layer instanceof OsmDataLayer) {
          ((OsmDataLayer) layer).removeLayerPropertyChangeListener(this);
        }

        layers.remove(layer);
        Main.removeProjectionChangeListener(layer);

      } finally {
        layerLock.writeLock().unlock();
      }
      onActiveEditLayerChanged(oldActiveLayer, oldEditLayer, listenersToFire);
      fireLayerRemoved(layer);
      layer.removePropertyChangeListener(this);
      layer.destroy();
      AudioPlayer.reset();
    } finally {
      layerLock.readLock().unlock();
    }
    repaint();
  }
예제 #14
0
  final void putForExternalRead(
      K key, V value, EnumSet<Flag> explicitFlags, ClassLoader explicitClassLoader) {
    Transaction ongoingTransaction = null;
    try {
      ongoingTransaction = getOngoingTransaction();
      if (ongoingTransaction != null) transactionManager.suspend();

      EnumSet<Flag> flags =
          EnumSet.of(
              FAIL_SILENTLY,
              FORCE_ASYNCHRONOUS,
              ZERO_LOCK_ACQUISITION_TIMEOUT,
              PUT_FOR_EXTERNAL_READ);
      if (explicitFlags != null && !explicitFlags.isEmpty()) {
        flags.addAll(explicitFlags);
      }

      // if the entry exists then this should be a no-op.
      putIfAbsent(
          key,
          value,
          defaultLifespan,
          TimeUnit.MILLISECONDS,
          defaultMaxIdleTime,
          TimeUnit.MILLISECONDS,
          flags,
          explicitClassLoader);
    } catch (Exception e) {
      if (log.isDebugEnabled()) log.debug("Caught exception while doing putForExternalRead()", e);
    } finally {
      try {
        if (ongoingTransaction != null) transactionManager.resume(ongoingTransaction);
      } catch (Exception e) {
        if (log.isDebugEnabled())
          log.debug("Had problems trying to resume a transaction after putForExternalRead()", e);
      }
    }
  }
  @Override
  public String browse(final Presentation context) {
    final Property property = property();

    final EnumSet<JavaTypeKind> kinds = EnumSet.noneOf(JavaTypeKind.class);

    if (this.paramKinds != null) {
      for (String kindString : this.paramKinds.split(",")) {
        kindString = kindString.trim();

        if (kindString.equalsIgnoreCase(JavaTypeKind.CLASS.name())) {
          kinds.add(JavaTypeKind.CLASS);
        } else if (kindString.equalsIgnoreCase(JavaTypeKind.ABSTRACT_CLASS.name())) {
          kinds.add(JavaTypeKind.ABSTRACT_CLASS);
        } else if (kindString.equalsIgnoreCase(JavaTypeKind.INTERFACE.name())) {
          kinds.add(JavaTypeKind.INTERFACE);
        } else if (kindString.equalsIgnoreCase(JavaTypeKind.ANNOTATION.name())) {
          kinds.add(JavaTypeKind.ANNOTATION);
        } else if (kindString.equalsIgnoreCase(JavaTypeKind.ENUM.name())) {
          kinds.add(JavaTypeKind.ENUM);
        } else {
          final String msg = typeKindNotRecognized.format(kindString);
          Sapphire.service(LoggingService.class).logError(msg);
        }
      }
    } else {
      final JavaTypeConstraintService javaTypeConstraintService =
          property.service(JavaTypeConstraintService.class);

      if (javaTypeConstraintService != null) {
        kinds.addAll(javaTypeConstraintService.kinds());
      }
    }

    int browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ALL_TYPES;
    int count = kinds.size();

    if (count == 1) {
      final JavaTypeKind kind = kinds.iterator().next();

      switch (kind) {
        case CLASS:
          browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES;
          break;
        case ABSTRACT_CLASS:
          browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES;
          break;
        case INTERFACE:
          browseDialogStyle = IJavaElementSearchConstants.CONSIDER_INTERFACES;
          break;
        case ANNOTATION:
          browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ANNOTATION_TYPES;
          break;
        case ENUM:
          browseDialogStyle = IJavaElementSearchConstants.CONSIDER_ENUMS;
          break;
        default:
          throw new IllegalStateException();
      }
    } else if (count == 2) {
      if (kinds.contains(JavaTypeKind.CLASS) || kinds.contains(JavaTypeKind.ABSTRACT_CLASS)) {
        if (kinds.contains(JavaTypeKind.INTERFACE)) {
          browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES;
        } else if (kinds.contains(JavaTypeKind.ENUM)) {
          browseDialogStyle = IJavaElementSearchConstants.CONSIDER_CLASSES_AND_ENUMS;
        }
      }
    }

    final IProject project = property.element().adapt(IProject.class);

    try {
      final SelectionDialog dlg =
          JavaUI.createTypeDialog(
              ((FormComponentPresentation) context).shell(),
              null,
              project,
              browseDialogStyle,
              false);

      dlg.setTitle(
          dialogTitle.format(
              property.definition().getLabel(true, CapitalizationType.TITLE_STYLE, false)));

      if (dlg.open() == SelectionDialog.OK) {
        Object results[] = dlg.getResult();
        assert results != null && results.length == 1;
        if (results[0] instanceof IType) {
          return ((IType) results[0]).getFullyQualifiedName();
        }
      }
    } catch (JavaModelException e) {
      Sapphire.service(LoggingService.class).log(e);
    }

    return null;
  }
예제 #16
0
 @Override
 public synchronized TextGraphics setModifiers(EnumSet<SGR> modifiers) {
   activeModifiers.clear();
   activeModifiers.addAll(modifiers);
   return this;
 }
예제 #17
0
 static {
   IDENTIFIER_FOLLOW_SET.addAll(DeclarationsParser.VAR_START_SET);
 }
예제 #18
0
 static {
   PARAMETER_FOLLOW_SET.addAll(DeclarationsParser.DECLARATION_START_SET);
 }
예제 #19
0
 public GroupJson addOptions(Collection<ListGroupsOption> o) {
   options.addAll(o);
   return this;
 }
 static {
   inverseSetFrom = EnumSet.of(CommandType.U3, CommandType.R1, CommandType.F3);
   inverseSetFrom.addAll(EnumSet.of(CommandType.D1, CommandType.L3, CommandType.B1));
 }
 static {
   normalSetFrom = EnumSet.of(CommandType.U1, CommandType.R3, CommandType.F1);
   normalSetFrom.addAll(EnumSet.of(CommandType.D3, CommandType.L1, CommandType.B3));
 }
 static {
   internalCommand = EnumSet.of(CommandType.COLOR, CommandType.SPEED);
   internalCommand.addAll(viewCommand);
 }
예제 #23
0
  /**
   * Creates a list of detectors applicable to the given cope, and with the given configuration.
   *
   * @param client the client to report errors to
   * @param configuration the configuration to look up which issues are enabled etc from
   * @param scope the scope for the analysis, to filter out detectors that require wider analysis
   *     than is currently being performed
   * @param scopeToDetectors an optional map which (if not null) will be filled by this method to
   *     contain mappings from each scope to the applicable detectors for that scope
   * @return a list of new detector instances
   */
  @NonNull
  final List<? extends Detector> createDetectors(
      @NonNull LintClient client,
      @NonNull Configuration configuration,
      @NonNull EnumSet<Scope> scope,
      @Nullable Map<Scope, List<Detector>> scopeToDetectors) {
    List<Issue> issues = getIssues();
    Set<Class<? extends Detector>> detectorClasses = new HashSet<Class<? extends Detector>>();
    Map<Class<? extends Detector>, EnumSet<Scope>> detectorToScope =
        new HashMap<Class<? extends Detector>, EnumSet<Scope>>();
    for (Issue issue : issues) {
      Class<? extends Detector> detectorClass = issue.getDetectorClass();
      EnumSet<Scope> issueScope = issue.getScope();
      if (!detectorClasses.contains(detectorClass)) {
        // Determine if the issue is enabled
        if (!configuration.isEnabled(issue)) {
          continue;
        }

        // Determine if the scope matches
        if (!issue.isAdequate(scope)) {
          continue;
        }

        detectorClass = client.replaceDetector(detectorClass);

        assert detectorClass != null : issue.getId();
        detectorClasses.add(detectorClass);
      }

      if (scopeToDetectors != null) {
        EnumSet<Scope> s = detectorToScope.get(detectorClass);
        if (s == null) {
          detectorToScope.put(detectorClass, issueScope);
        } else if (!s.containsAll(issueScope)) {
          EnumSet<Scope> union = EnumSet.copyOf(s);
          union.addAll(issueScope);
          detectorToScope.put(detectorClass, union);
        }
      }
    }

    List<Detector> detectors = new ArrayList<Detector>(detectorClasses.size());
    for (Class<? extends Detector> clz : detectorClasses) {
      try {
        Detector detector = clz.newInstance();
        detectors.add(detector);

        if (scopeToDetectors != null) {
          EnumSet<Scope> union = detectorToScope.get(clz);
          for (Scope s : union) {
            List<Detector> list = scopeToDetectors.get(s);
            if (list == null) {
              list = new ArrayList<Detector>();
              scopeToDetectors.put(s, list);
            }
            list.add(detector);
          }
        }
      } catch (Throwable t) {
        client.log(t, "Can't initialize detector %1$s", clz.getName()); // $NON-NLS-1$
      }
    }

    return detectors;
  }
예제 #24
0
 static {
   COMMA_SET.addAll(DeclarationsParser.DECLARATION_START_SET);
 }
예제 #25
0
 static {
   FIRST_SET = EnumSet.of(CONST, VAR, PROC, FUNC, TYPE);
   FOLLOW_SET = EnumSet.of(SEMICOLON, IN);
   FIRST_FOLLOW_SET = FIRST_SET.clone();
   FIRST_FOLLOW_SET.addAll(FOLLOW_SET);
 }
예제 #26
0
  /**
   * Parse a Triangle SingleDeclarationParser.
   *
   * <p>Single-Declaration ::= const Identifier ~ Expression | var Identifier : Type-Denoter | proc
   * Identifier (Formal-Parameter-Sequence) ~ Single-Command | func Identifier
   * (Formal-Parameter-Sequence) : Type-Denoter ~ Expression | Type Identifier ~ Type-Denoter
   *
   * <p>To be overridden by the specialized command parse subclasses.
   *
   * @param token the initial token.
   * @return the root node of the generated parse tree.
   * @throws Exception if an error occurred.
   */
  public void parse(Token token) throws Exception {
    SingleCommandParser singleCommand = null;
    ExpressionParser expression = null;
    FormalParameterSequenceParser formalParameterSequence = null;
    TypeDenoterParser typeDenoter = null;
    EnumSet<TriangleTokenType> syncSet = null;
    TypeSpec identifierType = TrianglePredefined.undefinedType;
    Token identifierToken = null;
    ICode routineICode = null;

    token = currentToken();

    switch ((TriangleTokenType) token.getType()) {
      case CONST:
        identifierToken = nextToken();
        syncSet = EnumSet.of(TILDE);
        syncSet.addAll(ExpressionParser.FIRST_FOLLOW_SET);
        synchronize(IDENTIFIER, MISSING_IDENTIFIER, syncSet);
        syncSet.remove(TILDE);
        token = synchronize(TILDE, MISSING_TILDE, syncSet);
        expression = new ExpressionParser(this);
        ICodeNode expressionNode = expression.parse(token);

        SymTabEntry constantId = symTabStack.lookupLocal(identifierToken.getText().toLowerCase());
        // Enter the new identifier into the symbol table
        // but don't set how it's defined yet.
        if (constantId == null) {
          constantId = symTabStack.enterLocal(identifierToken.getText().toLowerCase());
          constantId.setDefinition(DefinitionImpl.CONSTANT);
          constantId.setAttribute(CONSTANT_VALUE, expressionNode);
          constantId.appendLineNumber(identifierToken.getLineNumber());
          constantId.setTypeSpec(expressionNode.getTypeSpec());
        } else {
          errorHandler.flag(identifierToken, IDENTIFIER_REDEFINED, this);
        }
        break;
      case VAR:
        identifierToken = nextToken();
        syncSet = EnumSet.of(COLON);
        syncSet.addAll(TypeDenoterParser.FIRST_FOLLOW_SET);
        synchronize(IDENTIFIER, MISSING_IDENTIFIER, syncSet);

        syncSet.remove(COLON);
        token = synchronize(COLON, MISSING_COLON, syncSet);

        typeDenoter = new TypeDenoterParser(this);
        identifierType = typeDenoter.parse(token);

        SymTabEntry variableId = symTabStack.lookupLocal(identifierToken.getText().toLowerCase());
        // Enter the new identifier into the symbol table
        // but don't set how it's defined yet.
        if (variableId == null) {
          variableId = symTabStack.enterLocal(identifierToken.getText().toLowerCase());
          variableId.setDefinition(DefinitionImpl.VARIABLE);
          variableId.appendLineNumber(identifierToken.getLineNumber());
          variableId.setTypeSpec(identifierType);
        } else {
          errorHandler.flag(identifierToken, IDENTIFIER_REDEFINED, this);
        }
        break;
      case PROC:
        identifierToken = nextToken();
        routineICode = ICodeFactory.createICode();
        syncSet = EnumSet.of(LEFT_PAREN);
        syncSet.addAll(FormalParameterSequenceParser.FIRST_FOLLOW_SET);
        token = synchronize(IDENTIFIER, MISSING_IDENTIFIER, syncSet);
        syncSet.remove(LEFT_PAREN);
        token = synchronize(LEFT_PAREN, MISSING_LEFT_PAREN, syncSet);
        SymTabEntry procId = symTabStack.lookupLocal(identifierToken.getText().toLowerCase());
        // Enter the new identifier into the symbol table
        // but don't set how it's defined yet.
        if (procId == null) {
          procId = symTabStack.enterLocal(identifierToken.getText().toLowerCase());
          procId.setTypeSpec(TrianglePredefined.undefinedType);
          procId.setDefinition(DefinitionImpl.PROCEDURE);
          procId.appendLineNumber(identifierToken.getLineNumber());
          procId.setAttribute(ROUTINE_SYMTAB, symTabStack.push());
          procId.setAttribute(ROUTINE_ICODE, routineICode);
        } else {
          errorHandler.flag(identifierToken, IDENTIFIER_REDEFINED, this);
          procId = null;
        }

        formalParameterSequence = new FormalParameterSequenceParser(this);
        ArrayList<SymTabEntry> procParamList = formalParameterSequence.parse(token);
        syncSet = EnumSet.of(TILDE);
        syncSet.addAll(SingleCommandParser.FIRST_FOLLOW_SET);
        token = synchronize(RIGHT_PAREN, MISSING_RIGHT_PAREN, syncSet);
        syncSet.remove(TILDE);
        token = synchronize(TILDE, MISSING_TILDE, syncSet);
        singleCommand = new SingleCommandParser(this);
        routineICode.setRoot(singleCommand.parse(token));
        if (procId != null) {
          procId.setAttribute(ROUTINE_PARMS, procParamList);
        }
        symTabStack.pop();
        break;
      case FUNC:
        identifierToken = nextToken();
        routineICode = ICodeFactory.createICode();
        SymTabEntry funcId = symTabStack.lookupLocal(identifierToken.getText().toLowerCase());
        // Enter the new identifier into the symbol table
        // but don't set how it's defined yet.
        if (funcId == null) {
          funcId = symTabStack.enterLocal(identifierToken.getText().toLowerCase());
          funcId.setDefinition(DefinitionImpl.FUNCTION);
          funcId.appendLineNumber(identifierToken.getLineNumber());
          funcId.setTypeSpec(TrianglePredefined.undefinedType);
          funcId.setAttribute(ROUTINE_SYMTAB, symTabStack.push());
          funcId.setAttribute(ROUTINE_ICODE, routineICode);
        } else {
          errorHandler.flag(identifierToken, IDENTIFIER_REDEFINED, this);
          funcId = null;
        }
        syncSet = EnumSet.of(LEFT_PAREN);
        syncSet.addAll(FormalParameterSequenceParser.FIRST_FOLLOW_SET);
        token = synchronize(IDENTIFIER, MISSING_IDENTIFIER, syncSet);
        syncSet.remove(LEFT_PAREN);
        token = synchronize(LEFT_PAREN, MISSING_LEFT_PAREN, syncSet);
        formalParameterSequence = new FormalParameterSequenceParser(this);
        ArrayList<SymTabEntry> funcParamList = formalParameterSequence.parse(token);
        syncSet = EnumSet.of(COLON);
        syncSet.addAll(TypeDenoterParser.FIRST_FOLLOW_SET);
        synchronize(RIGHT_PAREN, MISSING_RIGHT_PAREN, syncSet);
        syncSet.remove(COLON);
        token = synchronize(COLON, MISSING_COLON, syncSet);
        Token typeToken = currentToken();
        typeDenoter = new TypeDenoterParser(this);
        TypeSpec funcType = typeDenoter.parse(token);
        syncSet = ExpressionParser.FIRST_FOLLOW_SET.clone();
        token = synchronize(TILDE, MISSING_TILDE, syncSet);
        expression = new ExpressionParser(this);
        routineICode.setRoot(expression.parse(token));
        if (funcId != null) {
          funcId.setTypeSpec(funcType);
          funcId.setAttribute(ROUTINE_PARMS, funcParamList);
          if (!routineICode.getRoot().getTypeSpec().equals(funcType)) {
            errorHandler.flag(typeToken, RETURN_TYPE_MISMATCH, this);
          }
        }
        symTabStack.pop();
        break;
      case TYPE:
        identifierToken = nextToken();
        syncSet = EnumSet.of(TILDE);
        syncSet.addAll(TypeDenoterParser.FIRST_FOLLOW_SET);
        synchronize(IDENTIFIER, MISSING_IDENTIFIER, syncSet);
        syncSet.remove(TILDE);
        token = synchronize(TILDE, MISSING_TILDE, syncSet);
        typeDenoter = new TypeDenoterParser(this);
        TypeSpec typeType = typeDenoter.parse(token);
        SymTabEntry typeId = symTabStack.lookupLocal(identifierToken.getText().toLowerCase());
        // Enter the new identifier into the symbol table
        // but don't set how it's defined yet.
        if (typeId == null) {
          typeId = symTabStack.enterLocal(identifierToken.getText().toLowerCase());
          typeId.setDefinition(DefinitionImpl.TYPE);
          typeId.appendLineNumber(identifierToken.getLineNumber());
          typeId.setTypeSpec(typeType);
        } else {
          errorHandler.flag(token, IDENTIFIER_REDEFINED, this);
        }
        break;
      default:
        errorHandler.flag(token, MISSING_DECLARATION, this);
        break;
    }
  }
예제 #27
0
 /** Returns the union of two enumsets */
 public static <E extends Enum<E>> EnumSet<E> union(EnumSet<E> s1, EnumSet<E> s2) {
   EnumSet<E> s = s1.clone();
   s.addAll(s2);
   return (s);
 }
예제 #28
0
 @Option(name = "-O", usage = "Output option flags, in hex")
 void setOptionFlagsHex(String hex) {
   options.addAll(ListChangesOption.fromBits(Integer.parseInt(hex, 16)));
 }
 protected ChangeInfo get(String id, ListChangesOption... options) throws RestApiException {
   EnumSet<ListChangesOption> s = EnumSet.noneOf(ListChangesOption.class);
   s.addAll(Arrays.asList(options));
   return gApi.changes().id(id).get(s);
 }