Examples of ProgramNode


Examples of macromedia.asc.parser.ProgramNode

        // version of this code
        CompilerContext flexCx = unit.getContext();
        // Don't do the HashMap lookup for the context. access strongly typed
        // variable for the ASC Context from CompilerContext
        Context cx = flexCx.getAscContext();
        ProgramNode node = (ProgramNode)unit.getSyntaxTree();

        // stop processing if unit.topLevelDefinitions.first() is null
        if (unit.topLevelDefinitions.first() == null)
        {
            return;
        }

        String className = NameFormatter.toDot(unit.topLevelDefinitions.first());
        boolean exclude = false;
        if (includeOnly != null && !includeOnly.contains(className))
        {
            exclude = true;
        }
        else if (excludeClasses.contains(className))
        {
            excludeClasses.remove(className);
            exclude = true;
        }
        // check the metadata for ExcludeClass. Like Flex Builder, ASDoc uses
        // this compiler metadata to
        // determine which classes should not be visible to the user
        else if (unit.metadata != null)
        {

            for (Iterator iterator = unit.metadata.iterator(); iterator.hasNext();)
            {
                MetaDataNode metaDataNode = (MetaDataNode)iterator.next();
                if (EXCLUDE_CLASS.equals(metaDataNode.getId()))
                {
                    exclude = true;
                    break;
                }
            }
        }

        // the inheritance needs to be processed in a predictable order..
        Set<QName> inheritance = new TreeSet<QName>(new ComparatorImpl());
       
        for (Name name : unit.inheritance)
        {
            if (name instanceof QName)
            {
                inheritance.add((QName) name);
            }
        }

        boolean flag = false;
        if (!exclude && !unit.getSource().isInternal())
        {
            if (Trace.asdoc)
                System.out.println("Generating XML for " + unit.getSource().getName());

            flag = false;
        }
        else
        {
            if (Trace.asdoc)
                System.out.println("Skipping generating XML for " + unit.getSource().getName());

            flag = true;
        }
       
        if (packages.size() != 0)
        {
            String n = unit.topLevelDefinitions.first().getNamespace();
            if (n != null)
            {
                packages.remove(n);
            }
        }

        cx.pushScope(node.frame);

        MetaDataEvaluator printer = new MetaDataEvaluator();
        node.evaluate(cx, printer);

        ObjectList comments = printer.doccomments;

        AbcClass abcClass = typeTable.getClass(unit.topLevelDefinitions.first().toString());
        tab.addComments(unit.topLevelDefinitions.first(), comments, inheritance, flag, cx, abcClass);
View Full Code Here

Examples of org.encog.ml.prg.ProgramNode

   */
  @Override
  public boolean rewrite(final Genome g) {
    this.rewritten = false;
    final EncogProgram program = (EncogProgram) g;
    final ProgramNode node = program.getRootNode();
    final ProgramNode rewrittenRoot = internalRewrite(node);
    if (rewrittenRoot != null) {
      program.setRootNode(rewrittenRoot);
    }
    return this.rewritten;
  }
View Full Code Here

Examples of org.encog.ml.prg.ProgramNode

   * Attempt to rewrite the specified node.
   * @param parent The node to attempt to rewrite.
   * @return The rewritten node, or the original node, if no change was made.
   */
  private ProgramNode internalRewrite(final ProgramNode parent) {
    ProgramNode rewrittenParent = parent;

    rewrittenParent = tryAnd(rewrittenParent);

    // try children
    for (int i = 0; i < rewrittenParent.getChildNodes().size(); i++) {
      final ProgramNode childNode = (ProgramNode) rewrittenParent
          .getChildNodes().get(i);
      final ProgramNode rewriteChild = internalRewrite(childNode);
      if (childNode != rewriteChild) {
        rewrittenParent.getChildNodes().remove(i);
        rewrittenParent.getChildNodes().add(i, rewriteChild);
        this.rewritten = true;
      }
View Full Code Here

Examples of org.encog.ml.prg.ProgramNode

   * @param parent The node to attempt to rewrite.
   * @return The rewritten node, or the original node if not rewritten.
   */
  private ProgramNode tryAnd(final ProgramNode parent) {
    if (parent.getTemplate() == StandardExtensions.EXTENSION_AND) {
      final ProgramNode child1 = parent.getChildNode(0);
      final ProgramNode child2 = parent.getChildNode(1);

      if (isTrue(child1)
          && child2.getTemplate() != StandardExtensions.EXTENSION_CONST_SUPPORT) {
        this.rewritten = true;
        return child2;
      }

      if (isTrue(child2)
View Full Code Here

Examples of org.encog.ml.prg.ProgramNode

   * @param v The value that the constant represents.
   * @return The newly created node.
   */
  private ProgramNode createNumericConst(final EncogProgram prg,
      final double v) {
    final ProgramNode result = prg.getFunctions().factorProgramNode("#const",
        prg, new ProgramNode[] {});
    result.getData()[0] = new ExpressionValue(v);
    return result;
  }
View Full Code Here

Examples of org.encog.ml.prg.ProgramNode

   * @param prg The program to create the constant for.
   * @param v The value that the constant represents.
   * @return The newly created node.
   */
  private ProgramNode createNumericConst(final EncogProgram prg, final int v) {
    final ProgramNode result = prg.getFunctions().factorProgramNode("#const",
        prg, new ProgramNode[] {});
    result.getData()[0] = new ExpressionValue(v);
    return result;
  }
View Full Code Here

Examples of org.encog.ml.prg.ProgramNode

   * Attempt to rewrite the specified node.
   * @param parent The parent node to start from.
   * @return The rewritten node, or the same node if no rewrite occurs.
   */
  private ProgramNode internalRewrite(final ProgramNode parent) {
    ProgramNode rewrittenParent = parent;

    rewrittenParent = tryDoubleNegative(rewrittenParent);
    rewrittenParent = tryMinusMinus(rewrittenParent);
    rewrittenParent = tryPlusNeg(rewrittenParent);
    rewrittenParent = tryVarOpVar(rewrittenParent);
    rewrittenParent = tryPowerZero(rewrittenParent);
    rewrittenParent = tryOnePower(rewrittenParent);
    rewrittenParent = tryZeroPlus(rewrittenParent);
    rewrittenParent = tryZeroDiv(rewrittenParent);
    rewrittenParent = tryZeroMul(rewrittenParent);
    rewrittenParent = tryMinusZero(rewrittenParent);

    // try children
    for (int i = 0; i < rewrittenParent.getChildNodes().size(); i++) {
      final ProgramNode childNode = (ProgramNode) rewrittenParent
          .getChildNodes().get(i);
      final ProgramNode rewriteChild = internalRewrite(childNode);
      if (childNode != rewriteChild) {
        rewrittenParent.getChildNodes().remove(i);
        rewrittenParent.getChildNodes().add(i, rewriteChild);
        this.rewritten = true;
      }
View Full Code Here

Examples of org.encog.ml.prg.ProgramNode

   */
  @Override
  public boolean rewrite(final Genome g) {
    this.rewritten = false;
    final EncogProgram program = (EncogProgram) g;
    final ProgramNode node = program.getRootNode();
    final ProgramNode rewrittenRoot = internalRewrite(node);
    if (rewrittenRoot != null) {
      program.setRootNode(rewrittenRoot);
    }
    return this.rewritten;
  }
View Full Code Here

Examples of org.encog.ml.prg.ProgramNode

   * @param parent The parent node to attempt to rewrite.
   * @return The rewritten node, if it was rewritten.
   */
  private ProgramNode tryDoubleNegative(final ProgramNode parent) {
    if (parent.getName().equals("-")) {
      final ProgramNode child = parent.getChildNode(0);
      if (child.getName().equals("-")) {
        final ProgramNode grandChild = child.getChildNode(0);
        this.rewritten = true;
        return grandChild;
      }
    }
    return parent;
View Full Code Here

Examples of org.encog.ml.prg.ProgramNode

   * @param parent The parent node to attempt to rewrite.
   * @return The rewritten node, if it was rewritten.
   */
  private ProgramNode tryMinusMinus(ProgramNode parent) {
    if (parent.getName().equals("-") && parent.getChildNodes().size() == 2) {
      final ProgramNode child1 = parent.getChildNode(0);
      final ProgramNode child2 = parent.getChildNode(1);

      if (child2.getName().equals("#const")) {
        final ExpressionValue v = child2.getData()[0];
        if (v.isFloat()) {
          final double v2 = v.toFloatValue();
          if (v2 < 0) {
            child2.getData()[0] = new ExpressionValue(-v2);
            parent = parent
                .getOwner()
                .getContext()
                .getFunctions()
                .factorProgramNode("+", parent.getOwner(),
                    new ProgramNode[] { child1, child2 });
          }
        } else if (v.isInt()) {
          final long v2 = v.toIntValue();
          if (v2 < 0) {
            child2.getData()[0] = new ExpressionValue(-v2);
            parent = parent
                .getOwner()
                .getContext()
                .getFunctions()
                .factorProgramNode("+", parent.getOwner(),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.