Package st.gravel.support.compiler.ast

Source Code of st.gravel.support.compiler.ast.Node$Node_Factory

package st.gravel.support.compiler.ast;

/*
  This file is automatically generated from typed smalltalk source. Do not edit by hand.
  (C) AG5.com
*/

import java.math.BigInteger;
import st.gravel.support.jvm.NonLocalReturn;
import st.gravel.support.compiler.ast.SourcePosition;
import st.gravel.support.compiler.ast.NodeVisitor;
import java.util.Set;
import java.util.HashSet;
import st.gravel.support.compiler.ast.AbsoluteReference;
import st.gravel.support.compiler.ast.SourcePrinter;
import st.gravel.support.compiler.ast.Expression;
import st.gravel.support.compiler.ast.SourcePointerRemover;

abstract public class Node extends Object implements Cloneable {

  public static Node_Factory factory = new Node_Factory();

  SourcePosition _sourcePosition;

  public static class Node_Factory extends st.gravel.support.jvm.SmalltalkFactory {

    public Node basicNew() {
      throw new RuntimeException("Node is an abstract class");
    }
  }

  public <X> X accept_(final NodeVisitor<X> _visitor) {
    return _visitor.visitNode_(this);
  }

  public java.util.Set<String> allLocalVarNames() {
    final java.util.Set<String>[] _s;
    _s = new java.util.Set[1];
    _s[0] = new java.util.HashSet();
    this.withAllNodesDo_(new st.gravel.support.jvm.Block1<Object, Node>() {

      @Override
      public Object value_(final Node _n) {
        return _n.localVarNamesDo_(new st.gravel.support.jvm.Block1<Object, String>() {

          @Override
          public Object value_(final String _nm) {
            return _s[0].add(_nm);
          }
        });
      }
    });
    return _s[0];
  }

  public boolean allNodesContains_(final st.gravel.support.jvm.Block1<Boolean, Node> _aBlock) {
    final Object _temp1 = new Object();
    try {
      this.allNodesDo_(new st.gravel.support.jvm.Block1<Object, Node>() {

        @Override
        public Object value_(final Node _each) {
          if (_aBlock.value_(_each)) {
            throw new NonLocalReturn(true, _temp1);
          }
          return Node.this;
        }
      });
      return false;
    } catch (NonLocalReturn nlr) {
      if (nlr.marker == _temp1) {
        return (boolean) nlr.returnValue;
      } else {
        throw nlr;
      }
    }
  }

  public Node allNodesDo_(final st.gravel.support.jvm.Block1<Object, Node> _aBlock) {
    this.nodesDo_(new st.gravel.support.jvm.Block1<Object, Node>() {

      @Override
      public Object value_(final Node _each) {
        return _each.withAllNodesDo_(_aBlock);
      }
    });
    return this;
  }

  public Node allNodesDo_pruneWhere_(final st.gravel.support.jvm.Block1<Object, Node> _aBlock, final st.gravel.support.jvm.Block1<Boolean, Node> _pruneBlock) {
    this.nodesDo_(new st.gravel.support.jvm.Block1<Object, Node>() {

      @Override
      public Object value_(final Node _each) {
        if (!_pruneBlock.value_(_each)) {
          return _each.withAllNodesDo_pruneWhere_(_aBlock, _pruneBlock);
        }
        return Node.this;
      }
    });
    return this;
  }

  public String[] comment() {
    return new String[] {};
  }

  public Node copy() {
    try {
      Node _temp1 = (Node) this.clone();
      _temp1.postCopy();
      return _temp1;
    } catch (CloneNotSupportedException e) {
      throw new RuntimeException(e);
    }
  }

  public boolean equals(final Object _anObject) {
    if (!(this.getClass() == _anObject.getClass())) {
      return false;
    }
    if (this._sourcePosition == null) {
      if (!(((Node) _anObject)._sourcePosition == null)) {
        return false;
      }
    } else {
      if (!st.gravel.support.jvm.ObjectExtensions.equals_(this._sourcePosition, ((Node) _anObject)._sourcePosition)) {
        return false;
      }
    }
    return true;
  }

  public Node_Factory factory() {
    return factory;
  }

  public String getDiskSource() {
    if (_sourcePosition == null) {
      return null;
    }
    return st.gravel.support.jvm.FilenameExtensions.contentsFrom_to_(_sourcePosition.sourceFile().asFile(), _sourcePosition.start(), _sourcePosition.stop());
  }

  public AbsoluteReference globalNamespace() {
    return null;
  }

  public String globalVarName() {
    return null;
  }

  public int hashCode() {
    return 3434;
  }

  public boolean hasReturnStatements() {
    final Object _temp1 = new Object();
    try {
      this.nodesDo_(new st.gravel.support.jvm.Block1<Object, Node>() {

        @Override
        public Object value_(final Node _each) {
          if (_each.hasReturnStatements()) {
            throw new NonLocalReturn(true, _temp1);
          }
          return Node.this;
        }
      });
      return false;
    } catch (NonLocalReturn nlr) {
      if (nlr.marker == _temp1) {
        return (boolean) nlr.returnValue;
      } else {
        throw nlr;
      }
    }
  }

  public boolean hasSuperSend() {
    return this.allNodesContains_(((st.gravel.support.jvm.Block1<Boolean, Node>) (new st.gravel.support.jvm.Block1<Boolean, Node>() {

      @Override
      public Boolean value_(final Node _each) {
        return (boolean) _each.isSuperNode();
      }
    })));
  }

  public boolean hierarchyReferencesSelfOrInstanceType() {
    final Object _temp1 = new Object();
    try {
      this.withAllNodesDo_(new st.gravel.support.jvm.Block1<Object, Node>() {

        @Override
        public Object value_(final Node _node) {
          if (_node.referencesSelfOrInstanceType()) {
            throw new NonLocalReturn(true, _temp1);
          }
          return Node.this;
        }
      });
      return false;
    } catch (NonLocalReturn nlr) {
      if (nlr.marker == _temp1) {
        return (boolean) nlr.returnValue;
      } else {
        throw nlr;
      }
    }
  }

  public boolean hierarchyReferencesVariable_(final String _aString) {
    final Object _temp1 = new Object();
    try {
      this.withAllNodesDo_(new st.gravel.support.jvm.Block1<Object, Node>() {

        @Override
        public Object value_(final Node _node) {
          if (_node.referencesVariable_(_aString)) {
            throw new NonLocalReturn(true, _temp1);
          }
          return Node.this;
        }
      });
      return false;
    } catch (NonLocalReturn nlr) {
      if (nlr.marker == _temp1) {
        return (boolean) nlr.returnValue;
      } else {
        throw nlr;
      }
    }
  }

  public Node initialize() {
    return this;
  }

  public boolean isArrayLiteralNode() {
    return false;
  }

  public boolean isAssignable() {
    return false;
  }

  public boolean isAssignmentNode() {
    return false;
  }

  public boolean isBlockNode() {
    return false;
  }

  public boolean isBlockNodeWithReturnStatements() {
    return false;
  }

  public boolean isBlockTypeNode() {
    return false;
  }

  public boolean isBooleanLiteralNode() {
    return false;
  }

  public boolean isBottomTypeNode() {
    return false;
  }

  public boolean isByteArrayLiteralNode() {
    return false;
  }

  public boolean isCharacterLiteralNode() {
    return false;
  }

  public boolean isCreateHolderNode() {
    return false;
  }

  public boolean isFixedPointLiteralNode() {
    return false;
  }

  public boolean isGenericTypeVariableNode() {
    return false;
  }

  public boolean isIntegerLiteralNode() {
    return false;
  }

  public boolean isMessageNode() {
    return false;
  }

  public boolean isMetaNode() {
    return false;
  }

  public boolean isNilLiteralNode() {
    return false;
  }

  public boolean isNonLocalReturnNode() {
    return false;
  }

  public boolean isReturnNode() {
    return false;
  }

  public boolean isSelfNode() {
    return false;
  }

  public boolean isSelfTypeNode() {
    return false;
  }

  public boolean isSequenceNode() {
    return false;
  }

  public boolean isStringLiteralNode() {
    return false;
  }

  public boolean isSuperNode() {
    return false;
  }

  public boolean isSymbolLiteralNode() {
    return false;
  }

  public boolean isTypeDefNode() {
    return false;
  }

  public boolean isTypeVariableNode() {
    return false;
  }

  public boolean isVariableNode() {
    return false;
  }

  public Node localVarNamesDo_(final st.gravel.support.jvm.Block1<Object, String> _aBlock) {
    return this;
  }

  public abstract Node nodesDo_(final st.gravel.support.jvm.Block1<Object, Node> _aBlock);

  public st.gravel.core.Symbol packageName() {
    if (_sourcePosition == null) {
      return null;
    }
    return _sourcePosition.sourceFile().packageName();
  }

  public Node postCopy() {
    return this;
  }

  public Node prettySourceOn_(final StringBuilder _aStream) {
    SourcePrinter.factory.on_(_aStream).visit_(this);
    return this;
  }

  public String prettySourceString() {
    final StringBuilder _aStream;
    _aStream = st.gravel.support.jvm.WriteStreamFactory.on_(new String());
    this.prettySourceOn_(_aStream);
    return _aStream.toString();
  }

  public Node printOn_(final StringBuilder _aStream) {
    final String _title;
    _title = this.factory().toString();
    _aStream.append(st.gravel.support.jvm.CharacterExtensions.isVowel(_title.charAt(0)) ? "an " : "a ");
    _aStream.append(_title);
    _aStream.append('[');
    this.sourceOn_(_aStream);
    _aStream.append(']');
    return this;
  }

  public Node pvtSetSourcePosition_(final SourcePosition _aSourcePosition) {
    _sourcePosition = _aSourcePosition;
    return this;
  }

  public boolean referencesSelfOrInstanceType() {
    return false;
  }

  public boolean referencesVariable_(final String _aString) {
    return false;
  }

  public Expression returnValue() {
    return null;
  }

  public abstract Node sourceOn_(final StringBuilder _aStream);

  public SourcePosition sourcePosition() {
    return _sourcePosition;
  }

  public String sourceString() {
    final StringBuilder _aStream;
    _aStream = st.gravel.support.jvm.WriteStreamFactory.on_(new String());
    this.sourceOn_(_aStream);
    return _aStream.toString();
  }

  public String toString() {
    final StringBuilder _aStream;
    _aStream = st.gravel.support.jvm.WriteStreamFactory.on_(new String());
    _aStream.append(this.factory().toString());
    _aStream.append('[');
    this.sourceOn_(_aStream);
    _aStream.append(']');
    return _aStream.toString();
  }

  public Node withAllNodesDo_(final st.gravel.support.jvm.Block1<Object, Node> _aBlock) {
    _aBlock.value_(this);
    this.allNodesDo_(_aBlock);
    return this;
  }

  public Node withAllNodesDo_pruneWhere_(final st.gravel.support.jvm.Block1<Object, Node> _aBlock, final st.gravel.support.jvm.Block1<Boolean, Node> _pruneBlock) {
    _aBlock.value_(this);
    this.allNodesDo_pruneWhere_(_aBlock, _pruneBlock);
    return this;
  }

  public Node withoutSourcePointers() {
    return SourcePointerRemover.factory.visit_(this);
  }

  public Node withSourcePosition_(final SourcePosition _aSourcePosition) {
    if (_sourcePosition == _aSourcePosition) {
      return Node.this;
    }
    return this.copy().pvtSetSourcePosition_(_aSourcePosition);
  }
}
TOP

Related Classes of st.gravel.support.compiler.ast.Node$Node_Factory

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.