@Override public PType caseALetDefExp(ALetDefExp node, TypeCheckInfo question) throws AnalysisException { node.setType(typeCheckLet(node, node.getLocalDefs(), node.getExpression(), question)); return node.getType(); }
@Override public PExp getContextNode(PExp stitch) { if (!exp.getLocalDefs().isEmpty()) { ALetDefExp letDefExp = new ALetDefExp(); letDefExp.setLocalDefs(exp.clone().getLocalDefs()); letDefExp.setExpression(stitch); return letDefExp; } else { return stitch; } }
/** * Creates a new tree field only constructor {@code ALetDefExp TAG=letDef} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param localDefs_ the {@link NodeList} node for the {@code localDefs} child of this {@link ALetDefExp} node * @param expression_ the {@link PExp} node for the {@code expression} child of this {@link ALetDefExp} node */ public ALetDefExp(ILexLocation location_, List<? extends PDefinition> localDefs_, PExp expression_) { super(null,location_); this.setLocalDefs(localDefs_); this.setExpression(expression_); }
/** * Returns a deep clone of this {@link ALetDefExp} node. * @return a deep clone of this {@link ALetDefExp} node */ public ALetDefExp clone() { return new ALetDefExp( _type, _location, cloneList(_localDefs), cloneNode(_expression) ); }
/** * Called by the {@link ALetDefExp} node from {@link ALetDefExp#apply(IPOFAnalysis)}. * @param node the calling {@link ALetDefExp} node */ public void caseALetDefExp(ALetDefExp node) throws AnalysisException { _visitedNodes.add(node); inALetDefExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } { List<PDefinition> copy = new ArrayList<PDefinition>(node.getLocalDefs()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getExpression() != null && !_visitedNodes.contains(node.getExpression())) { node.getExpression().apply(this); } outALetDefExp(node); }
@Override public ValueList caseALetDefExp(ALetDefExp exp, ObjectContext ctxt) throws AnalysisException { ValueList list = af.createPDefinitionListAssistant().getValues(exp.getLocalDefs(), ctxt); list.addAll(exp.getExpression().apply(THIS, ctxt)); return list; }
@Override public Value caseALetDefExp(ALetDefExp node, Context ctxt) throws AnalysisException { return evalLet(node, node.getLocation(), node.getLocalDefs(), node.getExpression(), "expression", ctxt); }
public static ALetDefExp newALetDefExp(ILexLocation start, List<PDefinition> localDefs, PExp readConnectiveExpression) { ALetDefExp result = new ALetDefExp(); initExpression(result, start); result.setLocalDefs(localDefs); result.setExpression(readConnectiveExpression); return result; }
ALetDefExp letExp = new ALetDefExp(); letExp.setType(def.getInvExpression().getType().clone()); List<PDefinition> invDefs = new Vector<PDefinition>(); AEqualsDefinition local = new AEqualsDefinition(); local.setTest(varExp); invDefs.add(local); letExp.setLocalDefs(invDefs); letExp.setExpression(def.getInvExpression().clone());
@Override public String getContext() { StringBuilder sb = new StringBuilder(); if (!exp.getLocalDefs().isEmpty()) { sb.append("let "); sb.append(Utils.listToString(exp.getLocalDefs())); sb.append(" in"); } return sb.toString(); } }
/** * Called by the {@link ALetDefExp} node from {@link ALetDefExp#apply(IAnalysis)}. * @param node the calling {@link ALetDefExp} node */ public void caseALetDefExp(ALetDefExp node, Q question) throws AnalysisException { _visitedNodes.add(node); inALetDefExp(node, question); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this, question); } { List<PDefinition> copy = new ArrayList<PDefinition>(node.getLocalDefs()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this, question); } } } if(node.getExpression() != null && !_visitedNodes.contains(node.getExpression())) { node.getExpression().apply(this, question); } outALetDefExp(node, question); }
@Override public PExp caseALetDefExp(ALetDefExp exp, Integer lineno) throws AnalysisException { PExp found = findExpressionBaseCase(exp, lineno); if (found != null) { return found; } found = af.createPDefinitionListAssistant().findExpression(exp.getLocalDefs(), lineno); if (found != null) { return found; } return exp.getExpression().apply(THIS, lineno); }
private PExp buildStructuralComparison(PExp left_exp, PExp right_exp, int measureLexical) { if (measureLexical == 0) // what about 1 measures? same as 0? { return AstExpressionFactory.newAGreaterNumericBinaryExp(left_exp, right_exp); } ALetDefExp let_exp = new ALetDefExp(); AValueDefinition left_def = buildValueDef(left_exp, LEFT_MEASURE_NAME); AValueDefinition right_def = buildValueDef(right_exp, RIGHT_MEASURE_NAME); List<PDefinition> localDefs = new LinkedList<PDefinition>(); localDefs.add(left_def); localDefs.add(right_def); let_exp.setLocalDefs(localDefs); // let left = [left expression], right=[right expression] // in ... // we don't strictly need the let in AVariableExp leftName_exp = wrapName(new LexNameToken(null, LEFT_MEASURE_NAME, null)); AVariableExp rightName_exp = wrapName(new LexNameToken(null, RIGHT_MEASURE_NAME, null)); // build the left < right structural comparison expression let_exp.setExpression(buildStructuralLessThan(leftName_exp, rightName_exp, 1, measureLexical).clone()); return let_exp; }
/** * Creates a new complete constructor {@code ALetDefExp} node with the given nodes as children. * @deprecated This method should not be used, use AstFactory instead. * The basic child nodes are removed from their previous parents. * @param localDefs_ the {@link NodeList} node for the {@code localDefs} child of this {@link ALetDefExp} node * @param expression_ the {@link PExp} node for the {@code expression} child of this {@link ALetDefExp} node */ public ALetDefExp(PType type_, ILexLocation location_, List<? extends PDefinition> localDefs_, PExp expression_) { super(type_,location_); this.setLocalDefs(localDefs_); this.setExpression(expression_); }
/** * Creates a deep clone of this {@link ALetDefExp} node while putting all * old node-new node relations in the map {@code oldToNewMap}. * @param oldToNewMap the map filled with the old node-new node relation * @return a deep clone of this {@link ALetDefExp} node */ public ALetDefExp clone(Map<INode,INode> oldToNewMap) { ALetDefExp node = new ALetDefExp( _type, _location, cloneList(_localDefs, oldToNewMap), cloneNode(_expression, oldToNewMap) ); oldToNewMap.put(this, node); return node; }
/** * Called by the {@link ALetDefExp} node from {@link ALetDefExp#apply(IAnalysis)}. * @param node the calling {@link ALetDefExp} node */ public void caseALetDefExp(ALetDefExp node) throws AnalysisException { _visitedNodes.add(node); inALetDefExp(node); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { node.getType().apply(this); } { List<PDefinition> copy = new ArrayList<PDefinition>(node.getLocalDefs()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { e.apply(this); } } } if(node.getExpression() != null && !_visitedNodes.contains(node.getExpression())) { node.getExpression().apply(this); } outALetDefExp(node); }
public LexNameList caseALetDefExp(ALetDefExp expression) throws org.overture.ast.analysis.AnalysisException { LexNameList list = af.createPDefinitionListAssistant().getOldNames(expression.getLocalDefs()); list.addAll(af.createPExpAssistant().getOldNames(expression.getExpression())); return list; }
ALetDefExp letDefExp = new ALetDefExp(); AEqualsDefinition localDef = new AEqualsDefinition(); localDef.setPattern(result.getPattern().clone()); List<PDefinition> defs = new LinkedList<PDefinition>(); defs.add(localDef); letDefExp.setLocalDefs(defs); letDefExp.setExpression(stitch); return letDefExp;
/** * Called by the {@link ALetDefExp} node from {@link ALetDefExp#apply(IAnalysis)}. * @param node the calling {@link ALetDefExp} node */ public A caseALetDefExp(ALetDefExp node) throws AnalysisException { _visitedNodes.add(node); A retVal = createNewReturnValue(node); mergeReturns(retVal,inALetDefExp(node)); if(node.getType() != null && !_visitedNodes.contains(node.getType())) { mergeReturns(retVal,node.getType().apply(this)); } { List<PDefinition> copy = new ArrayList<PDefinition>(node.getLocalDefs()); for( PDefinition e : copy) { if(!_visitedNodes.contains(e)) { mergeReturns(retVal,e.apply(this)); } } } if(node.getExpression() != null && !_visitedNodes.contains(node.getExpression())) { mergeReturns(retVal,node.getExpression().apply(this)); } mergeReturns(retVal,outALetDefExp(node)); return retVal; }
@Override public void caseALetDefExp(ALetDefExp node) throws AnalysisException { if (!proceed(node)) { return; } DefinitionInfo defInfo = new DefinitionInfo(node.getLocalDefs(), af); visitDefs(defInfo.getNodeDefs()); openScope(defInfo, node); node.getExpression().apply(this); endScope(defInfo); }