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

gw.lang.ir.expression.IRCompositeExpression Maven / Gradle / Ivy

There is a newer version: 1.18.2
Show newest version
/*
 * Copyright 2014 Guidewire Software, Inc.
 */

package gw.lang.ir.expression;

import gw.config.CommonServices;
import gw.lang.ir.IRExpression;
import gw.lang.ir.IRElement;
import gw.lang.ir.IRType;
import gw.lang.UnstableAPI;
import gw.lang.reflect.java.IJavaType;
import gw.lang.reflect.java.JavaTypes;
import gw.lang.reflect.java.JavaTypes;

import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;

@UnstableAPI
public class IRCompositeExpression extends IRExpression {
  private List _elements;

  public IRCompositeExpression(IRElement... elements) {
    _elements = new ArrayList(Arrays.asList(elements));

    for(IRElement element : _elements) {
      element.setParent(this);
    }
  }

  public IRCompositeExpression(List elements) {
    _elements = elements;

    for(IRElement element : _elements) {
      element.setParent(this);
    }
  }

  public List getElements() {
    return _elements;
  }

  public void addElement(IRElement element) {
    _elements.add(element);
    element.setParent( this );
  }

  @Override
  public IRType getType() {
    IRElement irElement = _elements.get(_elements.size() - 1);
    if (irElement instanceof IRExpression) {
      IRExpression expr = (IRExpression) irElement;
      return expr.getType();
    } else {
      return CommonServices.getGosuIndustrialPark().getIRTypeResolver().getDescriptor(JavaTypes.pVOID());
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy