Example #1
0
        /* (non-Javadoc)
         * @see br.cos.ufrj.lens.odyssey.tools.psw.parser.environment.Environment#addEnvironment(br.cos.ufrj.lens.odyssey.tools.psw.parser.environment.Environment)
         */
        public Environment addEnvironment(Environment env)
        {
            if (env == null)
            {
                return(this);
            }

            List <object> otherEnvNamedElements = env.getNamedElements();

            // check if names from env
            // do not clash with the names locally defined in this environment
            foreach (NamedElement element in otherEnvNamedElements)
            {
                if (this.lookupLocal(element.getName()) != null)
                {
                    throw new NameClashException(
                              "element with this name already exists");
                }
            }

            // now create a new Environment merging this environment with the env parameter.
            Environment result = EnvironmentFactoryManager.getInstance(oclPackage).getEnvironmentInstance();

            result.addNamedElements(this.getNamedElements());
            result.addNamedElements(env.getNamedElements());

            ((EnvironmentImpl)result).addVariableDeclarations(this.getVariableDeclarations());
            ((EnvironmentImpl)result).addVariableDeclarations(((EnvironmentImpl)env).getVariableDeclarations());

            return(result);
        }
Example #2
0
        /* (non-Javadoc)
         * @see br.cos.ufrj.lens.odyssey.tools.psw.parser.environment.Environment#nestedEnvironment()
         */
        public Environment nestedEnvironment()
        {
            EnvironmentImpl result = EnvironmentFactoryManager.getInstance(oclPackage).getNestedEnvironmentInstance();

            result.setParent(this);
            return(result);
        }
Example #3
0
 public void release()
 {
     EnvironmentFactoryManager.getInstance(oclPackage).releaseEnvironment(this);
 }