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