All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.extendj.ast.Unary Maven / Gradle / Ivy

/* This file was generated with JastAdd2 (http://jastadd.org) version 2.3.0 */
package org.extendj.ast;
import java.util.ArrayList;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.IOException;
import java.util.Set;
import beaver.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.LinkedHashSet;
import java.util.*;
import org.jastadd.util.PrettyPrintable;
import org.jastadd.util.PrettyPrinter;
import java.util.zip.*;
import java.io.*;
import org.jastadd.util.*;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
/**
 * @ast node
 * @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:253
 * @astdecl Unary : Expr ::= Operand:Expr;
 * @production Unary : {@link Expr} ::= Operand:{@link Expr};

 */
public abstract class Unary extends Expr implements Cloneable {
  /**
   * @aspect Java4PrettyPrint
   * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrint.jadd:621
   */
  public void prettyPrint(PrettyPrinter out) {
    out.print(printPreOp());
    out.print(getOperand());
    out.print(printPostOp());
  }
  /**
   * @aspect CreateBCode
   * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:1017
   */
  public void createBCode(CodeGeneration gen) {
    super.createBCode(gen);
    emitOperation(gen);
  }
  /**
   * @aspect AutoBoxingCodegen
   * @declaredat /home/jesper/git/extendj/java5/backend/AutoBoxingCodegen.jrag:332
   */
  protected void boxingGen(CodeGeneration gen) {
    getOperand().createBCode(gen);
    TypeDecl type = getOperand().type();
    if (type.isReferenceType()) {
      type.emitCastTo(gen, type());
    }
    emitOperation(gen);
  }
  /**
   * @declaredat ASTNode:1
   */
  public Unary() {
    super();
  }
  /**
   * Initializes the child array to the correct size.
   * Initializes List and Opt nta children.
   * @apilevel internal
   * @ast method
   * @declaredat ASTNode:10
   */
  public void init$Children() {
    children = new ASTNode[1];
  }
  /**
   * @declaredat ASTNode:13
   */
  @ASTNodeAnnotation.Constructor(
    name = {"Operand"},
    type = {"Expr"},
    kind = {"Child"}
  )
  public Unary(Expr p0) {
    setChild(p0, 0);
  }
  /** @apilevel low-level 
   * @declaredat ASTNode:22
   */
  protected int numChildren() {
    return 1;
  }
  /**
   * @apilevel internal
   * @declaredat ASTNode:28
   */
  public boolean mayHaveRewrite() {
    return false;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:32
   */
  public void flushAttrCache() {
    super.flushAttrCache();
    type_reset();
    unassignedAfter_Variable_reset();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:38
   */
  public void flushCollectionCache() {
    super.flushCollectionCache();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:42
   */
  public Unary clone() throws CloneNotSupportedException {
    Unary node = (Unary) super.clone();
    return node;
  }
  /**
   * Create a deep copy of the AST subtree at this node.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   * @deprecated Please use treeCopy or treeCopyNoTransform instead
   * @declaredat ASTNode:53
   */
  @Deprecated
  public abstract Unary fullCopy();
  /**
   * Create a deep copy of the AST subtree at this node.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   * @declaredat ASTNode:61
   */
  public abstract Unary treeCopyNoTransform();
  /**
   * Create a deep copy of the AST subtree at this node.
   * The subtree of this node is traversed to trigger rewrites before copy.
   * The copy is dangling, i.e. has no parent.
   * @return dangling copy of the subtree at this node
   * @apilevel low-level
   * @declaredat ASTNode:69
   */
  public abstract Unary treeCopy();
  /**
   * Replaces the Operand child.
   * @param node The new node to replace the Operand child.
   * @apilevel high-level
   */
  public void setOperand(Expr node) {
    setChild(node, 0);
  }
  /**
   * Retrieves the Operand child.
   * @return The current node used as the Operand child.
   * @apilevel high-level
   */
  @ASTNodeAnnotation.Child(name="Operand")
  public Expr getOperand() {
    return (Expr) getChild(0);
  }
  /**
   * Retrieves the Operand child.
   * 

This method does not invoke AST transformations.

* @return The current node used as the Operand child. * @apilevel low-level */ public Expr getOperandNoTransform() { return (Expr) getChildNoTransform(0); } /** * @aspect AutoBoxingCodegen * @declaredat /home/jesper/git/extendj/java5/backend/AutoBoxingCodegen.jrag:240 */ public void emitPostfix(CodeGeneration gen, int constant) { Expr operand = getOperand(); while (operand instanceof ParExpr) { operand = ((ParExpr) operand).getExpr(); } Access access = ((Access) operand).lastAccess(); access.createAssignLoadDest(gen); if (needsPush()) { access.createPushAssignmentResult(gen); } TypeDecl type = access.type().binaryNumericPromotion(typeInt()); access.type().emitCastTo(gen, type); // Added for AutoBoxing. type.emitPushConstant(gen, constant); type.add(gen); type.emitCastTo(gen, access.type()); access.emitStore(gen); } /** * @aspect AutoBoxingCodegen * @declaredat /home/jesper/git/extendj/java5/backend/AutoBoxingCodegen.jrag:260 */ public void emitPrefix(CodeGeneration gen, int constant) { Expr operand = getOperand(); while (operand instanceof ParExpr) { operand = ((ParExpr) operand).getExpr(); } Access access = ((Access) operand).lastAccess(); access.createAssignLoadDest(gen); TypeDecl type = access.type().binaryNumericPromotion(typeInt()); access.type().emitCastTo(gen, type); // Added for AutoBoxing. type.emitPushConstant(gen, constant); type.add(gen); type.emitCastTo(gen, access.type()); if (needsPush()) { access.createPushAssignmentResult(gen); } access.emitStore(gen); } /** * @attribute syn * @aspect PrettyPrintUtil * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:389 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="PrettyPrintUtil", declaredAt="/home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:389") public String printPostOp() { String printPostOp_value = ""; return printPostOp_value; } /** * @attribute syn * @aspect PrettyPrintUtil * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:393 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="PrettyPrintUtil", declaredAt="/home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:393") public String printPreOp() { String printPreOp_value = ""; return printPreOp_value; } /** @apilevel internal */ private void type_reset() { type_computed = null; type_value = null; } /** @apilevel internal */ protected ASTState.Cycle type_computed = null; /** @apilevel internal */ protected TypeDecl type_value; /** * @attribute syn * @aspect TypeAnalysis * @declaredat /home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:295 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="TypeAnalysis", declaredAt="/home/jesper/git/extendj/java4/frontend/TypeAnalysis.jrag:295") public TypeDecl type() { ASTState state = state(); if (type_computed == ASTState.NON_CYCLE || type_computed == state().cycle()) { return type_value; } type_value = getOperand().type(); if (state().inCircle()) { type_computed = state().cycle(); } else { type_computed = ASTState.NON_CYCLE; } return type_value; } /** * @attribute syn * @aspect DefiniteAssignment * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:268 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="DefiniteAssignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:268") public boolean assignedAfter(Variable v) { boolean assignedAfter_Variable_value = getOperand().assignedAfter(v); return assignedAfter_Variable_value; } /** @apilevel internal */ private void unassignedAfter_Variable_reset() { unassignedAfter_Variable_values = null; } protected java.util.Map unassignedAfter_Variable_values; @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN, isCircular=true) @ASTNodeAnnotation.Source(aspect="DefiniteUnassignment", declaredAt="/home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:899") public boolean unassignedAfter(Variable v) { Object _parameters = v; if (unassignedAfter_Variable_values == null) unassignedAfter_Variable_values = new java.util.HashMap(4); ASTState.CircularValue _value; if (unassignedAfter_Variable_values.containsKey(_parameters)) { Object _cache = unassignedAfter_Variable_values.get(_parameters); if (!(_cache instanceof ASTState.CircularValue)) { return (Boolean) _cache; } else { _value = (ASTState.CircularValue) _cache; } } else { _value = new ASTState.CircularValue(); unassignedAfter_Variable_values.put(_parameters, _value); _value.value = true; } ASTState state = state(); if (!state.inCircle() || state.calledByLazyAttribute()) { state.enterCircle(); boolean new_unassignedAfter_Variable_value; do { _value.cycle = state.nextCycle(); new_unassignedAfter_Variable_value = getOperand().unassignedAfter(v); if (((Boolean)_value.value) != new_unassignedAfter_Variable_value) { state.setChangeInCycle(); _value.value = new_unassignedAfter_Variable_value; } } while (state.testAndClearChangeInCycle()); unassignedAfter_Variable_values.put(_parameters, new_unassignedAfter_Variable_value); state.leaveCircle(); return new_unassignedAfter_Variable_value; } else if (_value.cycle != state.cycle()) { _value.cycle = state.cycle(); boolean new_unassignedAfter_Variable_value = getOperand().unassignedAfter(v); if (((Boolean)_value.value) != new_unassignedAfter_Variable_value) { state.setChangeInCycle(); _value.value = new_unassignedAfter_Variable_value; } return new_unassignedAfter_Variable_value; } else { return (Boolean) _value.value; } } /** * @attribute syn * @aspect PreciseRethrow * @declaredat /home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:145 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="PreciseRethrow", declaredAt="/home/jesper/git/extendj/java7/frontend/PreciseRethrow.jrag:145") public boolean modifiedInScope(Variable var) { boolean modifiedInScope_Variable_value = getOperand().modifiedInScope(var); return modifiedInScope_Variable_value; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:44 * @apilevel internal */ public boolean Define_isSource(ASTNode _callerNode, ASTNode _childNode) { if (getOperandNoTransform() != null && _callerNode == getOperand()) { // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:61 return true; } else { return getParent().Define_isSource(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:44 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute isSource */ protected boolean canDefine_isSource(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:235 * @apilevel internal */ public boolean Define_assignmentContext(ASTNode _callerNode, ASTNode _childNode) { if (getOperandNoTransform() != null && _callerNode == getOperand()) { // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:285 return false; } else { return getParent().Define_assignmentContext(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:235 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute assignmentContext */ protected boolean canDefine_assignmentContext(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:236 * @apilevel internal */ public boolean Define_invocationContext(ASTNode _callerNode, ASTNode _childNode) { if (getOperandNoTransform() != null && _callerNode == getOperand()) { // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:286 return false; } else { return getParent().Define_invocationContext(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:236 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute invocationContext */ protected boolean canDefine_invocationContext(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:237 * @apilevel internal */ public boolean Define_castContext(ASTNode _callerNode, ASTNode _childNode) { if (getOperandNoTransform() != null && _callerNode == getOperand()) { // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:287 return false; } else { return getParent().Define_castContext(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:237 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute castContext */ protected boolean canDefine_castContext(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:238 * @apilevel internal */ public boolean Define_stringContext(ASTNode _callerNode, ASTNode _childNode) { if (getOperandNoTransform() != null && _callerNode == getOperand()) { // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:288 return false; } else { return getParent().Define_stringContext(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:238 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute stringContext */ protected boolean canDefine_stringContext(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:239 * @apilevel internal */ public boolean Define_numericContext(ASTNode _callerNode, ASTNode _childNode) { if (getOperandNoTransform() != null && _callerNode == getOperand()) { // @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:289 return false; } else { return getParent().Define_numericContext(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java8/frontend/TargetType.jrag:239 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute numericContext */ protected boolean canDefine_numericContext(ASTNode _callerNode, ASTNode _childNode) { return true; } /** @apilevel internal */ public ASTNode rewriteTo() { return super.rewriteTo(); } /** @apilevel internal */ public boolean canRewrite() { return false; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy