/** * @return The current default module name. */ @Override public String getDefaultName() { return defaultModule.getName().getName(); }
public String toString() { return "" + "("+_object+"."+(_memberName == null ? _field.getName() : _memberName.getFullName())+")"; }
public List<String> getModules() throws Exception { List<String> names = new Vector<String>(); if (interpreter instanceof ClassInterpreter) { throw new Exception("Only available for VDM-SL"); } else { for (AModuleModules m : ((ModuleInterpreter) interpreter).getModules()) { names.add(m.getName().getName()); } } return names; }
@Override public void caseANewExp(ANewExp node) throws AnalysisException { super.caseANewExp(node); instantiatedClasses.add(node.getClassName().getName()); } });
private static AFieldField findField(ARecordInvariantType ty, ILexIdentifierToken id) { List<AFieldField> fields = ty.getFields(); for (AFieldField f : fields) { if (f.getTag().equals(id.getName())) { return f; } } return null; }
public LexNameToken(String module, ILexIdentifierToken id) { super(id.getLocation(), VDMToken.NAME); this.module = module; this.name = id.getName(); this.old = id.isOld(); this.explicit = false; }
public boolean isValidName(ILexIdentifierToken name) { return isNotNull(name) && isNotNull(name.getName()); }
@Override public String caseAFieldStateDesignator(AFieldStateDesignator node) throws AnalysisException { return node.getField().getName() + node.getField(); }
@Override public void caseILexIdentifierToken(ILexIdentifierToken node) throws AnalysisException { validateName(node.getName(), node.getLocation(), /* no module */ null); }
public String getNodeName(INode node) { if (node instanceof SClassDefinition) { return ((SClassDefinition) node).getName().getName(); } else if (node instanceof AModuleModules) { return ((AModuleModules) node).getName().getName(); } // Fall back return node.toString(); }
@Override protected boolean doModules(String line) { String def = minterpreter.getDefaultName(); List<AModuleModules> modules = minterpreter.getModules(); for (AModuleModules m : modules) { if (m.getName().getName().equals(def)) { println(m.getName().getName() + " (default)"); } else { println(m.getName().getName()); } } return true; }
public AModuleModulesRuntime(AModuleModules node, ITypeCheckerAssistantFactory af) { delegate = new Delegate(node.getName().getName(), node.getDefs()); this.assistantFactory = af; }
public LexNameToken getMemberName(AClassType cls, ILexIdentifierToken id) { // Note: not explicit return new LexNameToken(cls.getName().getName(), id.getName(), id.getLocation(), false, false); }
private AFromModuleImports importAll(ILexIdentifierToken from) { List<List<PImport>> types = new Vector<List<PImport>>(); ILexNameToken all = new LexNameToken(from.getName(), "all", from.getLocation()); List<PImport> impAll = new Vector<PImport>(); AAllImport iport = AstFactory.newAAllImport(all); iport.setLocation(all.getLocation()); iport.setName(all); iport.setRenamed(all); iport.setFrom(null); impAll.add(iport); types.add(impAll); return AstFactory.newAFromModuleImports(from, types); } }
@Override public PDefinition findType(ILexNameToken name, String fromModule) { PDefinition def = af.createPDefinitionAssistant().findType(module.getDefs(), name, module.getName().getName()); if (def != null) { return def; } def = af.createPDefinitionAssistant().findType(module.getImportdefs(), name, module.getName().getName()); if (def != null) { return def; } return null; // Modules are always bottom of the env chain }
public boolean isLibrary(INode node) { if (node instanceof SClassDefinition) { return isLibraryName(((SClassDefinition) node).getName().getName()); } else if (node instanceof AModuleModules) { return isLibraryName(((AModuleModules) node).getName().getName()); } return false; }
@Override public SModifierIR caseARecordModifier(ARecordModifier node, IRInfo question) throws AnalysisException { ILexIdentifierToken tag = node.getTag(); PExp value = node.getValue(); String name = tag.getName(); SExpIR recCg = value.apply(question.getExpVisitor(), question); ARecordModifierIR recModifier = new ARecordModifierIR(); recModifier.setName(name); recModifier.setValue(recCg); return recModifier; }
@Override public SStateDesignatorIR caseAFieldStateDesignator( AFieldStateDesignator node, IRInfo question) throws AnalysisException { PType type = node.getType(); PStateDesignator stateDesignator = node.getObject(); String fieldName = node.getField().getName(); STypeIR typeCg = type.apply(question.getTypeVisitor(), question); SStateDesignatorIR stateDesignatorCg = stateDesignator.apply(question.getStateDesignatorVisitor(), question); AFieldStateDesignatorIR field = new AFieldStateDesignatorIR(); field.setType(typeCg); field.setObject(stateDesignatorCg); field.setField(fieldName); return field; }
private SImportIR initImport(PImport vdmImport, SImportIR irImport) { String name = vdmImport.getName() != null ? vdmImport.getName().getName() : null; String renamed = vdmImport.getRenamed() != null ? vdmImport.getRenamed().getName() : null; String fromModuleName = vdmImport.getFrom() != null ? vdmImport.getFrom().getName().getName() : null; irImport.setName(name); irImport.setRenamed(renamed); irImport.setFromModuleName(fromModuleName); return irImport; } }