1 package org.simantics.scl.compiler.compilation;
3 import org.simantics.scl.compiler.elaboration.modules.SCLValue;
4 import org.simantics.scl.compiler.elaboration.modules.TypeDescriptor;
5 import org.simantics.scl.compiler.environment.AmbiguousNameException;
6 import org.simantics.scl.compiler.environment.Environment;
7 import org.simantics.scl.compiler.errors.ErrorLog;
8 import org.simantics.scl.compiler.top.SCLCompilerConfiguration;
10 public class NameExistenceChecks {
11 public static void checkIfValueExists(ErrorLog errorLog, long location,
12 Environment environment, String name) {
13 if(SCLCompilerConfiguration.ALLOW_OVERLOADING)
17 SCLValue value = environment.getLocalNamespace().getValue(name);
19 errorLog.log(location,
20 "Value " + name + " is already defined in the module " +
21 value.getName().module +
22 " that is imported to the default namespace.");
23 } catch(AmbiguousNameException e) {
24 errorLog.log(location,
25 "Value " + name + " is already defined in the modules " +
26 e.conflictingModules[0] + " and " + e.conflictingModules[1] +
27 " that are imported to the default namespace.");
32 public static void checkIfTypeExists(ErrorLog errorLog, long location,
33 Environment environment, String name) {
35 TypeDescriptor tdesc = environment.getLocalNamespace().getTypeDescriptor(name);
37 errorLog.log(location,
38 "Type " + name + " is already defined in the module " +
40 " that is imported to the default namespace.");
41 } catch(AmbiguousNameException e) {
42 errorLog.log(location,
43 "Type " + name + " is already defined in the modules " +
44 e.conflictingModules[0] + " and " + e.conflictingModules[1] +
45 " that are imported to the default namespace.");