Пример #1
0
 public void preBind() {
   try {
     preBindeding = true;
     try {
       moduleContext.pushErrors();
       IMemberBoundNode memberBoundNode =
           XlsBinder.this.beginBind(tableSyntaxNode, module, openl, moduleContext);
       childrens[index] = memberBoundNode;
       if (memberBoundNode != null) {
         try {
           memberBoundNode.addTo(module);
         } catch (OpenlNotCheckedException e) {
           SyntaxNodeException error = SyntaxNodeExceptionUtils.createError(e, tableSyntaxNode);
           processError(error, tableSyntaxNode, moduleContext);
         }
       }
     } finally {
       List<SyntaxNodeException> syntaxNodeExceptions = moduleContext.popErrors();
       for (SyntaxNodeException e : syntaxNodeExceptions) {
         addModuleContextError(e); // Workaround for syntax node
         // errors
       }
     }
     if (recursiveOpenMethodPreBinderMethods != null) {
       for (RecursiveOpenMethodPreBinder recursiveOpenMethodPreBinderMethod :
           recursiveOpenMethodPreBinderMethods) {
         recursiveOpenMethodPreBinderMethod.preBind();
       }
     }
   } finally {
     preBindeding = false;
   }
 }
Пример #2
0
  protected IBoundNode bindInternal(
      XlsModuleSyntaxNode moduleSyntaxNode,
      XlsModuleOpenClass module,
      TableSyntaxNode[] tableSyntaxNodes,
      OpenL openl,
      RulesModuleBindingContext moduleContext) {

    IMemberBoundNode[] children = new IMemberBoundNode[tableSyntaxNodes.length];
    OpenMethodHeader[] openMethodHeaders = new OpenMethodHeader[tableSyntaxNodes.length];

    for (int i = 0;
        i < tableSyntaxNodes.length;
        i++) { // Add methods that should be compiled recursively
      if (isExecutableTableSyntaxNode(tableSyntaxNodes[i])) {
        openMethodHeaders[i] =
            addMethodHeaderToContext(
                module, tableSyntaxNodes[i], openl, moduleContext, children, i);
      }
    }

    for (int i = 0; i < tableSyntaxNodes.length; i++) {
      if (!isExecutableTableSyntaxNode(tableSyntaxNodes[i])) {
        IMemberBoundNode child = beginBind(tableSyntaxNodes[i], module, openl, moduleContext);
        children[i] = child;
        if (child != null) {
          try {
            child.addTo(module);
          } catch (OpenlNotCheckedException e) {
            SyntaxNodeException error =
                SyntaxNodeExceptionUtils.createError(e, tableSyntaxNodes[i]);
            processError(error, tableSyntaxNodes[i], moduleContext);
          }
        }
      }
    }

    for (int i = 0; i < children.length; i++) {
      if (isExecutableTableSyntaxNode(tableSyntaxNodes[i])) {
        moduleContext.preBindMethod(openMethodHeaders[i]);
      }
    }

    for (int i = 0; i < children.length; i++) {
      if (children[i] != null) {
        finilizeBind(children[i], tableSyntaxNodes[i], moduleContext);
      }
    }

    processModuleContextErrors(moduleContext);

    if (moduleContext.isExecutionMode()) {
      removeDebugInformation(children, tableSyntaxNodes, moduleContext);
    }

    return new ModuleNode(moduleSyntaxNode, moduleContext.getModule());
  }
Пример #3
0
 private OpenMethodHeader addMethodHeaderToContext(
     XlsModuleOpenClass module,
     TableSyntaxNode tableSyntaxNode,
     OpenL openl,
     RulesModuleBindingContext moduleContext,
     IMemberBoundNode[] children,
     int index) {
   try {
     AExecutableNodeBinder aExecutableNodeBinder =
         (AExecutableNodeBinder) getBinderFactory().get(tableSyntaxNode.getType());
     IOpenSourceCodeModule source =
         aExecutableNodeBinder.createHeaderSource(tableSyntaxNode, moduleContext);
     OpenMethodHeader openMethodHeader =
         (OpenMethodHeader) OpenLManager.makeMethodHeader(openl, source, moduleContext);
     XlsBinderExecutableMethodBind xlsBinderExecutableMethodBind =
         new XlsBinderExecutableMethodBind(
             module, openl, tableSyntaxNode, children, index, openMethodHeader, moduleContext);
     moduleContext.addBinderMethod(openMethodHeader, xlsBinderExecutableMethodBind);
     return openMethodHeader;
   } catch (Exception e) {
     SyntaxNodeException error = SyntaxNodeExceptionUtils.createError(e, tableSyntaxNode);
     processError(error, tableSyntaxNode, moduleContext);
   }
   return null;
 }
Пример #4
0
 /**
  * Creates {@link RulesModuleBindingContext} and populates it with types from dependent modules.
  *
  * @param moduleNode just for processing error
  * @param bindingContext
  * @param moduleDependencies
  * @param moduleOpenClass
  * @return {@link RulesModuleBindingContext} created with bindingContext and moduleOpenClass.
  */
 private RulesModuleBindingContext populateBindingContextWithDependencies(
     XlsModuleSyntaxNode moduleNode,
     IBindingContext bindingContext,
     Set<CompiledDependency> moduleDependencies,
     XlsModuleOpenClass moduleOpenClass) {
   RulesModuleBindingContext moduleContext =
       createRulesBindingContext(bindingContext, moduleOpenClass);
   try {
     moduleContext.addTypes(
         filterDependencyTypes(moduleOpenClass.getTypes(), moduleContext.getInternalTypes()));
   } catch (Exception ex) {
     SyntaxNodeException error =
         SyntaxNodeExceptionUtils.createError(
             "Can`t add datatype from dependency", ex, moduleNode);
     BindHelper.processError(error);
   }
   return moduleContext;
 }
Пример #5
0
  private void processVocabulary(IVocabulary vocabulary, RulesModuleBindingContext moduleContext) {
    IOpenClass[] types = null;

    try {
      types = vocabulary.getVocabularyTypes();
    } catch (SyntaxNodeException error) {
      BindHelper.processError(error, moduleContext);
    }

    if (types != null) {

      for (int i = 0; i < types.length; i++) {

        try {
          moduleContext.addType(ISyntaxConstants.THIS_NAMESPACE, types[i]);
        } catch (Throwable t) {
          BindHelper.processError(null, t, moduleContext);
        }
      }
    }
  }