Package org.rascalmpl.ast

Examples of org.rascalmpl.ast.Expression$Product


        // We don't have a reference to the selected Product.
        // So first we have to lookup the object,
        // we do this by a query by example (QBE):
        // 1. build an example object with matching primary key values:
        Product example = new Product();
        example.setId(id);
        // 2. build a QueryByIdentity from this sample instance:
        Query query = new QueryByIdentity(example);
        try
        {
            // start broker transaction
            broker.beginTransaction();
            // lookup the product specified by the QBE
            Product toBeDeleted = (Product) broker.getObjectByQuery(query);
            // now ask broker to delete the object
            broker.delete(toBeDeleted);
            // commit transaction
            broker.commitTransaction();
        }
View Full Code Here


    /** perform this use case*/
    public void apply()
    {
        // this will be our new object
        Product newProduct = new Product();
       
        // thma: attention, no sequence numbers yet for ojb/prevalyer       
        newProduct.setId((int)System.currentTimeMillis());
       
        // now read in all relevant information and fill the new object:
        System.out.println("please enter a new product");
        String in = readLineWithMessage("enter name:");
        newProduct.setName(in);
        in = readLineWithMessage("enter price:");
        newProduct.setPrice(Double.parseDouble(in));
        in = readLineWithMessage("enter available stock:");
        newProduct.setStock(Integer.parseInt(in));

        // now perform persistence operations
        try
        {
            // 1. open transaction
View Full Code Here

        return processFormals(formals);
      }
     
      private String processFormals(List<Expression> formals) {
        if (formals.size() > 0) {
          Expression first = formals.get(0);
         
          if (first.isAsType()) {
            first = first.getArgument();
          }
          else if (first.isTypedVariableBecomes() || first.isVariableBecomes()) {
            first = first.getPattern();
          }
         
          if (first.isCallOrTree() && first.getExpression().isQualifiedName()) {
            return ((org.rascalmpl.semantics.dynamic.QualifiedName.Default) first.getExpression().getQualifiedName()).lastName();
          }
        }

        return null;
      }
View Full Code Here

   
    formals = params.getFormals().getFormals();
   
    if (params.isVarArgs() && formals.size() > 0) {
      // deal with varags, change the last argument to a list if its not a pattern
      Expression last = formals.get(formals.size() - 1);
      if (last.isTypedVariable()) {
        org.rascalmpl.ast.Type oldType = last.getType();
        ISourceLocation origin = last.getLocation();
        Structured newType = ASTBuilder.make("Type","Structured", origin, ASTBuilder.make("StructuredType",origin, ASTBuilder.make("BasicType","List", origin), Arrays.asList(ASTBuilder.make("TypeArg","Default", origin,oldType))));
        last = ASTBuilder.make("Expression","TypedVariable",origin, newType, last.getName());
        formals = replaceLast(formals, last);
      }
      else if (last.isQualifiedName()) {
        ISourceLocation origin = last.getLocation();
        org.rascalmpl.ast.Type newType = ASTBuilder.make("Type","Structured",origin, ASTBuilder.make("StructuredType",origin, ASTBuilder.make("BasicType","List", origin), Arrays.asList(ASTBuilder.make("TypeArg",origin, ASTBuilder.make("Type","Basic", origin, ASTBuilder.make("BasicType","Value", origin))))));
        last = ASTBuilder.makeExp("TypedVariable", origin, newType, Names.lastName(last.getQualifiedName()));
        formals = replaceLast(formals, last);
      }
      else {
        throw new UnsupportedPattern("...", last);
      }
View Full Code Here

        return processFormals(formals);
      }
     
      private IConstructor processFormals(List<Expression> formals) {
        if (formals.size() > 0) {
          Expression first = formals.get(0);
         
          if (first.isAsType()) {
            first = first.getArgument();
          }
          else if (first.isTypedVariableBecomes() || first.isVariableBecomes()) {
            first = first.getPattern();
          }
         
          if (first instanceof Tree.Appl) {
            Tree.Appl appl = (Appl) first;
            return appl.getProduction();
View Full Code Here

    throw new NonGroundSymbolException();
  }
 
  @Override
  public IConstructor visitExpressionCallOrTree(CallOrTree x) {
    Expression namePart = x.getExpression();
    if (!namePart.isQualifiedName()) {
      throw new ImplementationError("weird AST");
    }
    String name = ((org.rascalmpl.semantics.dynamic.QualifiedName.Default) namePart.getQualifiedName()).lastName();
   
    if (name.equals("lit")) {
      StringConstant.Lexical arg =
        (org.rascalmpl.ast.StringConstant.Lexical) x.getArguments().get(0).getLiteral().getStringLiteral().getConstant();
      // TODO: escaping etc.
View Full Code Here

    if (pattern.isVariableBecomes() || pattern.isTypedVariableBecomes()) {
      pattern = pattern.getPattern();
    }
   
    if (pattern.isCallOrTree()) {
      Expression func =  pattern.getExpression();
      if (func.isQualifiedName() && IUPTR_NAMES.contains(Names.fullName(func.getQualifiedName()))) {
        return true;
      }
    }

    return false;
View Full Code Here

    public boolean allConcrete = false;
    public abstract boolean matchAndEval(IEvaluator<Result<IValue>> eval, Result<IValue> subject);
   
    protected void computePredicates(Case c) {
      if (c.hasPatternWithAction()) {
        Expression pattern = c.getPatternWithAction().getPattern();
        hasRegExp |= pattern.isLiteral() && pattern.getLiteral().isRegExp();

        Type type = pattern._getType();
        allConcrete &= isNonTerminalType(type);
      }
    }
View Full Code Here

      allConcrete = true;
      hasRegExp = false;
    }
   
    void add(Case c) {
      Expression pattern = c.getPatternWithAction().getPattern();
      if (pattern.isVariableBecomes() || pattern.isTypedVariableBecomes()) {
        pattern = pattern.getPattern();
      }

      IConstructor key = ((Tree.Appl) pattern).getProduction();
      List<DefaultBlock> same = table.get(key);
      if (same == null) {
View Full Code Here

      hasRegExp = false;
      allConcrete = false;
    }

    void add(Case c) {
      Expression pattern = c.getPatternWithAction().getPattern();
      org.rascalmpl.ast.Expression name;
      if (pattern.isVariableBecomes() || pattern.isTypedVariableBecomes()) {
        name = pattern.getPattern().getExpression();
      }
      else {
        name = pattern.getExpression();
      }
      String key = null;

      if (name.isQualifiedName()) {
        key = ((QualifiedName.Default) name.getQualifiedName()).lastName();
View Full Code Here

TOP

Related Classes of org.rascalmpl.ast.Expression$Product

Copyright © 2018 www.massapicom. 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.