private InterprEnvironment()
 {
     m_current_namespace = new ConsoleNamespace();
     m_console_vars = m_current_namespace as ConsoleNamespace;
     m_not_restored = false;
     try {
         m_console_vars.Restore();
     } catch {
         m_not_restored = true;
         m_console_vars = new ConsoleNamespace();
         m_current_namespace = m_console_vars;
     }
 }
Esempio n. 2
0
		public Namespace(Namespace previous) {
			m_previous_namespace = previous;
		}
Esempio n. 3
0
        //****************************************************************************************************
		public VarBase Perform(ArgList al) {
			Namespace ns = new Namespace(InterprEnvironment.Instance.CurrentNamespace);
			ns["result"] = new IntVar(0);
			int argc = m_args.Count;
			if (al.Count != argc)
				throw new CalcException("Ќеверное число параметров");
			al.Reset();
			for (int i = 0; i < argc; i++) {
				ns[m_args[i] as System.String] = al.Get();
			}
			InterprEnvironment.Instance.CurrentNamespace = ns;
			Moment moment = new Moment(this);
			if (m_count > 1) {
				try {
					moment.Run();
				}
				catch (SyntaxErrorException ex) {
					throw ex;
				}
				catch (CalcException ex) {
					throw new CalcException("ќшибка в функции " + m_name + "[] в строке " + (moment.Pos + 1) + " : " + ex.Message);
				}
			}
			VarBase res = ns["result"];
			InterprEnvironment.Instance.CurrentNamespace = ns.PreviousNamespace;
			if (res == null)
				throw new CalcException("ќшибка в функции " + m_name + "[] : переменна¤ result не определена на момент выхода");
			return res;
		}