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

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

There is a newer version: 8.1.2
Show newest version
/* This file was generated with JastAdd2 (http://jastadd.org) version 2.3.0 */
package org.extendj.ast;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
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.*;
import java.util.zip.*;
import java.io.*;
import org.jastadd.util.PrettyPrintable;
import org.jastadd.util.PrettyPrinter;
import org.jastadd.util.*;
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.io.BufferedInputStream;
import java.io.DataInputStream;
/**
 * @ast node
 * @declaredat /home/jesper/git/extendj/java4/grammar/Java.ast:198
 * @astdecl AssignSimpleExpr : AssignExpr;
 * @production AssignSimpleExpr : {@link AssignExpr};

 */
public class AssignSimpleExpr extends AssignExpr implements Cloneable {
  /**
   * Create bytecode for a simple assign expression.
   * @aspect CreateBCode
   * @declaredat /home/jesper/git/extendj/java4/backend/CreateBCode.jrag:343
   */
  public void createBCode(CodeGeneration gen) {
    getDest().createAssignSimpleLoadDest(gen);
    getSource().createBCode(gen);
    getSource().emitAssignConvTo(gen, getDest().type());
    if (needsPush()) {
      getDest().createPushAssignmentResult(gen);
    }
    getDest().emitStore(gen);
  }
  /**
   * @declaredat ASTNode:1
   */
  public AssignSimpleExpr() {
    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[2];
  }
  /**
   * @declaredat ASTNode:13
   */
  @ASTNodeAnnotation.Constructor(
    name = {"Dest", "Source"},
    type = {"Expr", "Expr"},
    kind = {"Child", "Child"}
  )
  public AssignSimpleExpr(Expr p0, Expr p1) {
    setChild(p0, 0);
    setChild(p1, 1);
  }
  /** @apilevel low-level 
   * @declaredat ASTNode:23
   */
  protected int numChildren() {
    return 2;
  }
  /**
   * @apilevel internal
   * @declaredat ASTNode:29
   */
  public boolean mayHaveRewrite() {
    return false;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:33
   */
  public void flushAttrCache() {
    super.flushAttrCache();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:37
   */
  public void flushCollectionCache() {
    super.flushCollectionCache();
  }
  /** @apilevel internal 
   * @declaredat ASTNode:41
   */
  public AssignSimpleExpr clone() throws CloneNotSupportedException {
    AssignSimpleExpr node = (AssignSimpleExpr) super.clone();
    return node;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:46
   */
  public AssignSimpleExpr copy() {
    try {
      AssignSimpleExpr node = (AssignSimpleExpr) clone();
      node.parent = null;
      if (children != null) {
        node.children = (ASTNode[]) children.clone();
      }
      return node;
    } catch (CloneNotSupportedException e) {
      throw new Error("Error: clone not supported for " + getClass().getName());
    }
  }
  /**
   * 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:65
   */
  @Deprecated
  public AssignSimpleExpr fullCopy() {
    return treeCopyNoTransform();
  }
  /**
   * 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:75
   */
  public AssignSimpleExpr treeCopyNoTransform() {
    AssignSimpleExpr tree = (AssignSimpleExpr) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
        ASTNode child = (ASTNode) children[i];
        if (child != null) {
          child = child.treeCopyNoTransform();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }
  /**
   * 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:95
   */
  public AssignSimpleExpr treeCopy() {
    AssignSimpleExpr tree = (AssignSimpleExpr) copy();
    if (children != null) {
      for (int i = 0; i < children.length; ++i) {
        ASTNode child = (ASTNode) getChild(i);
        if (child != null) {
          child = child.treeCopy();
          tree.setChild(child, i);
        }
      }
    }
    return tree;
  }
  /** @apilevel internal 
   * @declaredat ASTNode:109
   */
  protected boolean is$Equal(ASTNode node) {
    return super.is$Equal(node);    
  }
  /**
   * Replaces the Dest child.
   * @param node The new node to replace the Dest child.
   * @apilevel high-level
   */
  public void setDest(Expr node) {
    setChild(node, 0);
  }
  /**
   * Retrieves the Dest child.
   * @return The current node used as the Dest child.
   * @apilevel high-level
   */
  @ASTNodeAnnotation.Child(name="Dest")
  public Expr getDest() {
    return (Expr) getChild(0);
  }
  /**
   * Retrieves the Dest child.
   * 

This method does not invoke AST transformations.

* @return The current node used as the Dest child. * @apilevel low-level */ public Expr getDestNoTransform() { return (Expr) getChildNoTransform(0); } /** * Replaces the Source child. * @param node The new node to replace the Source child. * @apilevel high-level */ public void setSource(Expr node) { setChild(node, 1); } /** * Retrieves the Source child. * @return The current node used as the Source child. * @apilevel high-level */ @ASTNodeAnnotation.Child(name="Source") public Expr getSource() { return (Expr) getChild(1); } /** * Retrieves the Source child. *

This method does not invoke AST transformations.

* @return The current node used as the Source child. * @apilevel low-level */ public Expr getSourceNoTransform() { return (Expr) getChildNoTransform(1); } /** * @attribute syn * @aspect TypeCheck * @declaredat /home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:77 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="TypeCheck", declaredAt="/home/jesper/git/extendj/java4/frontend/TypeCheck.jrag:77") public Collection typeProblems() { { Collection problems = new LinkedList(); if (!getDest().isVariable()) { problems.add(error("left hand side is not a variable")); } else if (!getSource().type().assignConversionTo(getDest().type(), getSource()) && !getSource().type().isUnknown()) { problems.add(errorf("can not assign %s of type %s a value of type %s", getDest().prettyPrint(), getDest().type().typeName(), getSource().type().typeName())); } return problems; } } /** The operator string used for pretty printing this expression. * @attribute syn * @aspect PrettyPrintUtil * @declaredat /home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:299 */ @ASTNodeAnnotation.Attribute(kind=ASTNodeAnnotation.Kind.SYN) @ASTNodeAnnotation.Source(aspect="PrettyPrintUtil", declaredAt="/home/jesper/git/extendj/java4/frontend/PrettyPrintUtil.jrag:299") public String printOp() { String printOp_value = "="; return printOp_value; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:34 * @apilevel internal */ public boolean Define_isDest(ASTNode _callerNode, ASTNode _childNode) { if (getDestNoTransform() != null && _callerNode == getDest()) { // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:36 return true; } else { return super.Define_isDest(_callerNode, _childNode); } } /** * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:34 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute isDest */ protected boolean canDefine_isDest(ASTNode _callerNode, ASTNode _childNode) { return true; } /** * @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:44 * @apilevel internal */ public boolean Define_isSource(ASTNode _callerNode, ASTNode _childNode) { if (getDestNoTransform() != null && _callerNode == getDest()) { // @declaredat /home/jesper/git/extendj/java4/frontend/DefiniteAssignment.jrag:46 return false; } else { return super.Define_isSource(_callerNode, _childNode); } } /** * @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/java5/frontend/GenericMethodsInference.jrag:69 * @apilevel internal */ public TypeDecl Define_assignConvertedType(ASTNode _callerNode, ASTNode _childNode) { if (getSourceNoTransform() != null && _callerNode == getSource()) { // @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethodsInference.jrag:71 return getDest().type(); } else { return getParent().Define_assignConvertedType(this, _callerNode); } } /** * @declaredat /home/jesper/git/extendj/java5/frontend/GenericMethodsInference.jrag:69 * @apilevel internal * @return {@code true} if this node has an equation for the inherited attribute assignConvertedType */ protected boolean canDefine_assignConvertedType(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