@Override
 public void computeChildren(final @NotNull XCompositeNode node) {
   Promise<Void> promise =
       Variables.processScopeVariables(scope, node, context, callFrame == null);
   if (callFrame != null) {
     promise.done(
         new ObsolescentConsumer<Void>(node) {
           @Override
           public void consume(Void ignored) {
             callFrame
                 .getReceiverVariable()
                 .done(
                     new ObsolescentConsumer<Variable>(node) {
                       @Override
                       public void consume(Variable variable) {
                         node.addChildren(
                             variable == null
                                 ? XValueChildrenList.EMPTY
                                 : XValueChildrenList.singleton(
                                     new VariableView(variable, context)),
                             true);
                       }
                     })
                 .rejected(
                     new ObsolescentConsumer<Throwable>(node) {
                       @Override
                       public void consume(@Nullable Throwable error) {
                         node.addChildren(XValueChildrenList.EMPTY, true);
                       }
                     });
           }
         });
   }
 }
Пример #2
0
    /**
     * Expands all flags in this group and adds them to {@code commandLine}.
     *
     * <p>The flags of the group will be expanded either:
     *
     * <ul>
     *   <li>once, if there is no variable of sequence type in any of the group's flags, or
     *   <li>for each element in the sequence, if there is one variable of sequence type within the
     *       flags.
     * </ul>
     *
     * <p>Having more than a single variable of sequence type in a single flag group is not
     * supported.
     */
    private void expandCommandLine(Variables variables, final List<String> commandLine) {
      variables.forEachExpansion(
          new Variables.ExpansionConsumer() {
            @Override
            public Set<String> getUsedVariables() {
              return usedVariables;
            }

            @Override
            public void expand(Map<String, String> variables) {
              for (Flag flag : flags) {
                flag.expandCommandLine(variables, commandLine);
              }
            }
          });
    }
  @Override
  public Object getOrNull(String name) {

    // Defined?
    Object value = variableValues.get(name);
    if (value != null) {
      return value == nullValue ? null : value;
    }

    // Contextual variable?
    if (contextualVariables != null) {
      value = contextualVariables.getOrNull(name);
      if (value != null) {
        return value == nullValue ? null : value;
      }
    }

    // Undefined.
    return null;
  }
  @Override
  public Object get(TextContext context, String name) {

    // Defined?
    Object value = variableValues.get(name);
    if (value != null) {
      return value == nullValue ? null : value;
    }

    // Contextual variable?
    if (contextualVariables != null) {
      value = contextualVariables.getOrNull(name);
      if (value != null) {
        return value == nullValue ? null : value;
      }
    }

    // Undefined.
    throw new ScriptException(context, "The variable '" + name + "' is undefined.");
  }
Пример #5
0
 public Double getStatus() throws IllegalStateException {
   if (Variables.isDefined(id + Variables.STATUS_SUFFIX)) {
     return (Double) Variables.getValue(id + Variables.STATUS_SUFFIX);
   }
   throw new IllegalStateException("Mission state of mission " + id + " not defined!");
 }
Пример #6
0
 public void setStatus(Double status) {
   Variables.setValue(Variables.SYSTEM_PREFIX + id + Variables.STATUS_SUFFIX, status);
 }
 public static Variable nuevaTemp(Character tipo) {
   Variable v = Variables.GuardarVariable("t" + contTemp++, tipo);
   v.nivel(0);
   return v;
 }
Пример #8
0
 public void insertVariables(Variables variables) {
   ints.putAll(variables.getInteger());
   chars.putAll(variables.getCharacter());
 }