// Path: src/main/java/gov/nasa/jpf/constraints/types/Type.java
// public interface Type<T> {
// 
//   public String getName();
//   
//   public String[] getOtherNames();
//   
//   public Class<T> getCanonicalClass();
// 
//   public Class<?>[] getOtherClasses();
// 
//   public T cast(Object other);
// 
//   public T getDefaultValue();
// 
//   public Type<?> getSuperType();
// 
//   public <O> CastOperation<? super O,? extends T> cast(Type<O> fromType);
//   public <O> CastOperation<? super O,? extends T> requireCast(Type<O> fromType);
// 
//   public abstract T parse(String string);
// 
//   
// 	
// }
// 
// Path: src/main/java/gov/nasa/jpf/constraints/util/AbstractPrintable.java
// public abstract class AbstractPrintable implements Printable {
// 
//   @Override
//   public String toString() {
//     try {
//       StringBuilder sb = new StringBuilder();
//       print(sb);
//       return sb.toString();
//     }
//     catch(IOException ex) {
//       throw new IllegalStateException("Unexpected IOException while writing to StringBuilder", ex);
//     }
//   }
// }


import gov.nasa.jpf.constraints.types.Type;
import gov.nasa.jpf.constraints.util.AbstractPrintable;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
/*
 * Copyright (C) 2015, United States Government, as represented by the 
 * Administrator of the National Aeronautics and Space Administration.
 * All rights reserved.
 *
 * The PSYCO: A Predicate-based Symbolic Compositional Reasoning environment 
 * platform is licensed under the Apache License, Version 2.0 (the "License"); you 
 * may not use this file except in compliance with the License. You may obtain a 
 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. 
 *
 * Unless required by applicable law or agreed to in writing, software distributed 
 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 * specific language governing permissions and limitations under the License.
 */
package gov.nasa.jpf.constraints.api;





/**
 * Expressions consist of terms, and can be evaluated E
 */
public abstract class Expression<E> extends AbstractPrintable {
  
  
  public static final int QUOTE_IDENTIFIERS = 1;
  public static final int INCLUDE_VARIABLE_TYPE = 2;
  public static final int INCLUDE_BOUND_DECL_TYPE = 4;
  public static final int SIMPLE_PROP_OPERATORS = 8;
  
  public static final int DEFAULT_FLAGS = QUOTE_IDENTIFIERS | INCLUDE_BOUND_DECL_TYPE;
  
  public static final int JAVA_COMPAT_FLAGS = SIMPLE_PROP_OPERATORS;
  
  public static boolean quoteIdentifiers(int printFlags) {
    return (printFlags & QUOTE_IDENTIFIERS) == QUOTE_IDENTIFIERS;
  }
  
  public static boolean includeVariableType(int printFlags) {
    return (printFlags & INCLUDE_VARIABLE_TYPE) == INCLUDE_VARIABLE_TYPE;
  }
  
  public static boolean includeBoundDeclType(int printFlags) {
    return (printFlags & INCLUDE_BOUND_DECL_TYPE) == INCLUDE_BOUND_DECL_TYPE;
  }
  
  public static Expression<?>[] NO_CHILDREN = new Expression[0];
  
    
  /**
   * evaluates using the provided values for symbolic variables
   * 
   * @param values
   * @return 
   */
  public abstract E evaluate(Valuation values);  
  
  /**
   * collect all symbolic variables
   * 
   * @param names 
   */
  public abstract void collectFreeVariables(Collection<? super Variable<?>> variables);
  
  public abstract <R,D> R accept(ExpressionVisitor<R, D> visitor, D data);
  
  
// Path: src/main/java/gov/nasa/jpf/constraints/types/Type.java
// public interface Type<T> {
// 
//   public String getName();
//   
//   public String[] getOtherNames();
//   
//   public Class<T> getCanonicalClass();
// 
//   public Class<?>[] getOtherClasses();
// 
//   public T cast(Object other);
// 
//   public T getDefaultValue();
// 
//   public Type<?> getSuperType();
// 
//   public <O> CastOperation<? super O,? extends T> cast(Type<O> fromType);
//   public <O> CastOperation<? super O,? extends T> requireCast(Type<O> fromType);
// 
//   public abstract T parse(String string);
// 
//   
// 	
// }
// 
// Path: src/main/java/gov/nasa/jpf/constraints/util/AbstractPrintable.java
// public abstract class AbstractPrintable implements Printable {
// 
//   @Override
//   public String toString() {
//     try {
//       StringBuilder sb = new StringBuilder();
//       print(sb);
//       return sb.toString();
//     }
//     catch(IOException ex) {
//       throw new IllegalStateException("Unexpected IOException while writing to StringBuilder", ex);
//     }
//   }
// }


// Path: src/main/java/gov/nasa/jpf/constraints/api/Expression.java
import gov.nasa.jpf.constraints.types.Type;
import gov.nasa.jpf.constraints.util.AbstractPrintable;
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
import java.util.Set;

/*
 * Copyright (C) 2015, United States Government, as represented by the 
 * Administrator of the National Aeronautics and Space Administration.
 * All rights reserved.
 *
 * The PSYCO: A Predicate-based Symbolic Compositional Reasoning environment 
 * platform is licensed under the Apache License, Version 2.0 (the "License"); you 
 * may not use this file except in compliance with the License. You may obtain a 
 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. 
 *
 * Unless required by applicable law or agreed to in writing, software distributed 
 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 * specific language governing permissions and limitations under the License.
 */
package gov.nasa.jpf.constraints.api;





/**
 * Expressions consist of terms, and can be evaluated E
 */
public abstract class Expression<E> extends AbstractPrintable {
  
  
  public static final int QUOTE_IDENTIFIERS = 1;
  public static final int INCLUDE_VARIABLE_TYPE = 2;
  public static final int INCLUDE_BOUND_DECL_TYPE = 4;
  public static final int SIMPLE_PROP_OPERATORS = 8;
  
  public static final int DEFAULT_FLAGS = QUOTE_IDENTIFIERS | INCLUDE_BOUND_DECL_TYPE;
  
  public static final int JAVA_COMPAT_FLAGS = SIMPLE_PROP_OPERATORS;
  
  public static boolean quoteIdentifiers(int printFlags) {
    return (printFlags & QUOTE_IDENTIFIERS) == QUOTE_IDENTIFIERS;
  }
  
  public static boolean includeVariableType(int printFlags) {
    return (printFlags & INCLUDE_VARIABLE_TYPE) == INCLUDE_VARIABLE_TYPE;
  }
  
  public static boolean includeBoundDeclType(int printFlags) {
    return (printFlags & INCLUDE_BOUND_DECL_TYPE) == INCLUDE_BOUND_DECL_TYPE;
  }
  
  public static Expression<?>[] NO_CHILDREN = new Expression[0];
  
    
  /**
   * evaluates using the provided values for symbolic variables
   * 
   * @param values
   * @return 
   */
  public abstract E evaluate(Valuation values);  
  
  /**
   * collect all symbolic variables
   * 
   * @param names 
   */
  public abstract void collectFreeVariables(Collection<? super Variable<?>> variables);
  
  public abstract <R,D> R accept(ExpressionVisitor<R, D> visitor, D data);
  
  
  public abstract Type<E> getType();