Package org.eclipse.xtext.xbase.interpreter

Examples of org.eclipse.xtext.xbase.interpreter.IEvaluationContext


        final EObject executable = IterableExtensions.<EObject>head(_sourceElements);
        Object _xifexpression = null;
        if ((executable instanceof Executable)) {
          Object _xblockexpression_1 = null;
          {
            final IEvaluationContext context = this.createContext();
            QualifiedName _create = QualifiedName.create("this");
            context.newValue(_create, this.tortoise);
            int index = 0;
            EList<JvmFormalParameter> _parameters = operation.getParameters();
            for (final JvmFormalParameter param : _parameters) {
              {
                String _name = param.getName();
                QualifiedName _create_1 = QualifiedName.create(_name);
                Object _get = argumentValues.get(index);
                context.newValue(_create_1, _get);
                index = (index + 1);
              }
            }
            XBlockExpression _body = ((Executable)executable).getBody();
            final IEvaluationResult result = this.evaluate(_body, context, CancelIndicator.NullImpl);
View Full Code Here


  @Override
  protected Object invokeOperation(JvmOperation operation, Object receiver, List<Object> argumentValues, IEvaluationContext c, CancelIndicator indicator) {
    XMethodDeclaration m = getMethodDeclaration(operation);
    if (m != null) {
      IEvaluationContext context = c.fork();
      int index = 0;
      for (JvmFormalParameter p : m.getParameters()) {
        context.newValue(QualifiedName.create(p.getName()), argumentValues.get(index));
        index++;
      }
      IEvaluationResult result = evaluate(m.getBody(), context, indicator);
      if (result.getException() != null) {
        result.getException().printStackTrace();
View Full Code Here

    return null;
  }

  private String interpret(final Model m, final IProgressMonitor monitor) {
    final List<String> data = new ArrayList<String>();
    IEvaluationContext context = new DefaultEvaluationContext();
    context.newValue(qualifiedNameConverter.toQualifiedName(IModelQueryConstants.INFERRED_CLASS_NAME + "." + IModelQueryConstants.INDEX), resourceDescriptions);
    context.newValue(qualifiedNameConverter.toQualifiedName(IModelQueryConstants.INFERRED_CLASS_NAME + "." + IModelQueryConstants.RESOURCESET), resourceSetProvider.get());
    context.newValue(qualifiedNameConverter.toQualifiedName(IModelQueryConstants.INFERRED_CLASS_NAME + "." + IModelQueryConstants.INJECTOR), injector);
    for (XImportDeclaration i : m.getImports().getImportDeclarations()) {
      data.add(serializer.serialize(i).trim());
    }
    for (XMethodDeclaration d : m.getMethods()) {
      data.add(serializer.serialize(d).trim());
View Full Code Here

        return ((RuleContextAdapter) adapter).getContext();
      }
    }
   
    // no evaluation context found, so create a new one
      IEvaluationContext evaluationContext = contextProvider.get();
      for(XExpression expr : ruleModel.getVariables()) {
        if (expr instanceof XVariableDeclaration) {
        XVariableDeclaration var = (XVariableDeclaration) expr;
        try {
            Object initialValue = var.getRight()==null ? null : scriptEngine.newScriptFromXExpression(var.getRight()).execute();
          evaluationContext.newValue(QualifiedName.create(var.getName()), initialValue);
        } catch (ScriptExecutionException e) {
          logger.warn("Variable '{}' on rule file '{}' cannot be initialized with value '{}': {}",
              new String[] { var.getName(), ruleModel.eResource().getURI().path(), var.getRight().toString(), e.getMessage() });
        }
      }
View Full Code Here

  XExpression getXExpression() {
    return xExpression;
  }
 
  public Object execute() throws ScriptExecutionException {
      IEvaluationContext evaluationContext = contextProvider.get();
      return execute(evaluationContext);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.xtext.xbase.interpreter.IEvaluationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.