@Override public String caseAValueDefinition(AValueDefinition node, PrettyPrinterEnv question) throws AnalysisException { StringBuilder sb = new StringBuilder(question.getIdent()); sb.append(node.getPattern() + (node.getType() == null ? "" : ":" + node.getType().apply(typePrinter, question)) + (node.getExpression() != null ? " = " + node.getExpression() : ""));// node.toString()); return sb.toString() + ";"; }
@Override public PType caseAValueDefinition(AValueDefinition node) throws AnalysisException { // return AValueDefinitionAssistantTC.getType((AValueDefinition) node); return node.getType() != null ? node.getType() : node.getExpType() != null ? node.getExpType() : AstFactory.newAUnknownType(node.getLocation()); }
public ValueBindingObligation(AValueDefinition def, IPOContextStack ctxt, IPogAssistantFactory af) throws AnalysisException { this(def.getPattern(), def.getType(), def.getExpression(), ctxt, af); }
@Override public LexNameSet caseAValueDefinition(AValueDefinition node, FreeVarInfo info) throws AnalysisException { LexNameSet names = new LexNameSet(); if (node.getType() != null) { names.addAll(node.getType().apply(this, info)); } names.addAll(node.getExpression().apply(this, info)); return names; }
@Override public void caseAValueDefinition(AValueDefinition node, NewQuestion question) throws AnalysisException { if (node.getType() != null) { node.setType(af.createPTypeAssistant().typeResolve(node.getType(), null, question.rootVisitor, question.question)); af.createPPatternAssistant().typeResolve(node.getPattern(), question.rootVisitor, question.question); // af.createAValueDefinitionAssistant().updateDefs(node, question.question); updateDefs(node, question.question); } }
private AVarDeclIR consLocalVarDecl(AValueDefinition valueDef, IRInfo question) throws AnalysisException { STypeIR type = valueDef.getType().apply(question.getTypeVisitor(), question); SPatternIR pattern = valueDef.getPattern().apply(question.getPatternVisitor(), question); SExpIR exp = valueDef.getExpression().apply(question.getExpVisitor(), question); return consLocalVarDecl(valueDef, type, pattern, exp); }
TypeCheckInfo question) throws AnalysisException if (node.getType() != null) question.assistantFactory.getTypeComparator().checkComposeTypes(node.getType(), question.env, false); question = question.newConstraint(node.getType()); ExcludedDefinitions.clearExcluded(); node.setExpType(expType); PType type = node.getType(); // PDefinitionAssistant.getType(node); return node.getType(); return node.getType();
@Override public SDeclIR caseAValueDefinition(AValueDefinition node, IRInfo question) throws AnalysisException { String access = node.getAccess().getAccess().toString(); String name = node.getPattern().toString(); boolean isStatic = true; boolean isFinal = true; PType type = node.getType(); PExp exp = node.getExpression(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); SExpIR expCg = exp.apply(question.getExpVisitor(), question); return question.getDeclAssistant().constructField(access, name, isStatic, isFinal, typeCg, expCg); }
public void updateDefs(AValueDefinition node, TypeCheckInfo question) { PType type = node.getType(); PPattern pattern = node.getPattern(); List<PDefinition> newdefs = af.createPPatternAssistant().getDefinitions(pattern, type, node.getNameScope()); // The untyped definitions may have had "used" markers, so we copy // those into the new typed definitions, lest we get warnings. We // also mark the local definitions as "ValueDefintions" (proxies), // so that classes can be constructed correctly (values are statics). for (PDefinition d : newdefs) { for (PDefinition u : node.getDefs()) { if (u.getName().equals(d.getName())) { if (af.createPDefinitionAssistant().isUsed(u)) { af.createPDefinitionAssistant().markUsed(d); } break; } } ALocalDefinition ld = (ALocalDefinition) d; ld.setValueDefinition(node.clone()); } node.setDefs(newdefs); List<PDefinition> defs = node.getDefs(); af.createPDefinitionListAssistant().setAccessibility(defs, node.getAccess().clone()); af.createPDefinitionListAssistant().setClassDefinition(defs, node.getClassDefinition()); }
PType type = node.getType();