@Override public String defaultPDefinition(PDefinition node, PrettyPrinterEnv question) throws AnalysisException { return node.apply(ppDefinition, question); }
public String toString() { return "" + ""+(_readOnly ? "ext rd " : "ext wr ")+_state.getName(); }
public static AInheritedDefinition newAInheritedDefinition( ILexNameToken localname, PDefinition d) { AInheritedDefinition result = new AInheritedDefinition(); initDefinition(result, d.getPass(), d.getLocation(), localname, d.getNameScope()); result.setSuperdef(d); result.setOldname(localname.getOldName()); result.setType(d.getType()); af.createPDefinitionAssistant().setClassDefinition(result, d.getClassDefinition()); result.setAccess(d.getAccess().clone()); return result; }
private static void initDefinition(PDefinition result, Pass values, ILexLocation location, ILexNameToken name, NameScope scope) { result.setPass(values); result.setLocation(location); result.setName(name); result.setNameScope(scope); result.setAccess(getDefaultAccessSpecifier()); result.setUsed(false); }
public void typeCheck(List<PDefinition> defs, IQuestionAnswer<TypeCheckInfo, PType> rootVisitor, TypeCheckInfo question) throws AnalysisException { for (PDefinition d : defs) { if (d.getName() != null && d.getName().getName().equals("RESULT")) { TypeCheckerErrors.report(3336, "Illegal use of RESULT reserved identifier", d.getLocation(), d); } d.apply(rootVisitor, question); } }
public static String getDefinitionListString( NodeList<? extends PDefinition> _definitions) { StringBuilder sb = new StringBuilder(); for (PDefinition d : _definitions) { if (d.getAccess() != null) { sb.append(d.getAccess()); sb.append(" "); } // sb.append(d.getClass().getName() + " " + getVariableNames(d) + ":" + d.getType()); sb.append(d.toString()); sb.append("\n"); } return sb.toString(); }
/** * Check a DefinitionList for incompatible duplicate pattern definitions. * * @param d * @param defs * @return */ public List<PDefinition> checkDuplicatePatterns(PDefinition d, List<PDefinition> defs) { Set<PDefinition> noDuplicates = new HashSet<PDefinition>(); for (PDefinition d1 : defs) { for (PDefinition d2 : defs) { if (d1 != d2 && d1.getName() != null && d2.getName() != null && d1.getName().equals(d2.getName())) { if (!af.getTypeComparator().compatible(d1.getType(), d2.getType())) { TypeCheckerErrors.report(3322, "Duplicate patterns bind to different types", d.getLocation(), d); TypeCheckerErrors.detail2(d1.getName().getName(), d1.getType(), d2.getName().getName(), d2.getType()); } } } noDuplicates.add(d1); } return new Vector<PDefinition>(noDuplicates); }
if (def != null && def.getNameScope() == null) def.setNameScope(NameScope.GLOBAL); if (def != null && !def.getLocation().equals(n1.getLocation()) && def.getNameScope().matches(scope)) if (def.getLocation().getFile().equals(n1.getLocation().getFile())) message = def.getName() + " " + def.getLocation().toShortString() + " hidden by " + n1.getFullName(); } else message = def.getName() + " " + def.getLocation() + " hidden by " + n1.getFullName();
public QualifiedDefinition(PDefinition qualifies, PType type) { this.def = qualifies; this.type = type; this.original = qualifies.getType(); }
if (vardef.getClassDefinition() != null) SClassDefinition sd = vardef.getClassDefinition(); if (sd != null && node.getName().getModule().equals("")) + vardef.getClassDefinition().getName().getName(), node.getLocation(), node); node.setType(AstFactory.newAUnknownType(node.getLocation())); return node.getType(); } else if ( !question.assistantFactory.createPAccessSpecifierAssistant().isStatic(vardef.getAccess()) && env.isStatic()) PType pt = possible.getType();
PDefinition found = d.apply(this, question);// PDefinitionAssistantTC.findName(d, question.sought, if (!def.getLocation().equals(found.getLocation()) && af.createPDefinitionAssistant().isFunctionOrOperation(def)) TypeCheckerErrors.detail2("1", def.getLocation(), "2", found.getLocation()); break; PDefinition indef = d.apply(this, question);// PDefinitionAssistantTC.findName(d, question.sought, } else if (def.equals(indef) !def.getLocation().equals(indef.getLocation()) && !af.createPDefinitionAssistant().hasSupertype(def.getClassDefinition(), indef.getClassDefinition().getType()) && af.createPDefinitionAssistant().isFunctionOrOperation(def)) + question.sought + " is multiply defined in class", question.sought.getLocation(), question.sought); TypeCheckerErrors.detail2("1", def.getLocation(), "2", indef.getLocation()); break;
public void unusedCheckBaseCase(PDefinition d) { if (!af.createPDefinitionAssistant().isUsed(d)) { TypeCheckerErrors.warning(5000, "Definition '" + d.getName() + "' not used", d.getLocation(), d); markUsed(d); // To avoid multiple warnings } }
d.setClassDefinition(cdef); d.setAccess(question.assistantFactory.createPAccessSpecifierAssistant().getStatic(d, true)); d.apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers)); } else d.apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope)); local = new FlatCheckedEnvironment(question.assistantFactory, d, local, question.scope); // cumulative
private void checkKind(ITypeCheckerAssistantFactory af, PDefinition actual, boolean expected, String expkind, PImport node) throws AnalysisException { if (actual != null && !expected) { String actkind = actual.apply(af.getKindFinder()); TypeCheckerErrors.report(3356, "Import of " + expkind + " " + actual.getName() + " is " + actkind, node.getLocation(), node); } } }
@Override public PType caseABlockSimpleBlockStm(ABlockSimpleBlockStm node, TypeCheckInfo question) throws AnalysisException { // Each dcl definition is in scope for later definitions... Environment local = question.env; for (PDefinition d : node.getAssignmentDefs()) { local = new FlatCheckedEnvironment(question.assistantFactory, d, local, question.scope); // cumulative question.assistantFactory.createPDefinitionAssistant().implicitDefinitions(d, local); d.setType(question.assistantFactory.createPTypeAssistant().typeResolve(d.getType(), null, THIS, question)); d.apply(THIS, new TypeCheckInfo(question.assistantFactory, local, question.scope, question.qualifiers, d.getType(), question.returnType)); } // For type checking purposes, the definitions are treated as // local variables. At runtime (below) they have to be treated // more like (updatable) state. PType r = defaultSSimpleBlockStm(node, new TypeCheckInfo(question.assistantFactory, local, question.scope, null, null, question.returnType)); local.unusedCheck(question.env); node.setType(r); return r; }
protected void stateInPre(List<PExp> args, PDefinition stateDefinition) { AVariableExp varExp; if (stateDefinition instanceof AStateDefinition) { varExp = getVarExp(OLD_STATE_ARG,stateDefinition.clone()); varExp.setType(((AStateDefinition) stateDefinition).getRecordType().clone()); } else { varExp = getVarExp(OLD_SELF_ARG,stateDefinition.clone()); varExp.setType(stateDefinition.getType().clone()); } args.add(varExp); }
ILexNameToken synthname = f.getName().getModifiedName(classname.getName()); PTypeSet current = null; AAccessSpecifierAccessSpecifier acc = f.getAccess().clone(); acc.setAccess(new APublicAccess()); // Guaranteed to be accessible else if (!curracc.getPure() && f.getAccess().getPure()) f.getAccess().getStatic() != null, f.getAccess().getAsync() != null, curracc.getPure() || f.getAccess().getPure()); (newname == null ? synthname : newname), NameScope.GLOBAL, ptype); def.setAccess(access.get(synthname).clone()); newdefs.add(def);
public static AImportedDefinition newAImportedDefinition( ILexLocation location, PDefinition d) { AImportedDefinition result = new AImportedDefinition(); initDefinition(result, Pass.DEFS, location, d.getName(), d.getNameScope()); result.setDef(d); return result; }
@Override public ILexLocation defaultPDefinition(PDefinition node) throws AnalysisException { return node.getLocation(); }