Beispiel #1
0
 public void Execute(Subroutine.Moment pos)
 {
     VarBase v = m_expr.Calculate();
     if (!v.IsSingle())
         throw new CalcException("«начение услови¤ не может быть массивом");
     if ((v as SingleVar).ToBool()) {
         pos.Next();
     }
     else {
         int pos1 = m_nextpos;
         while (true) {
             pos.GoTo(pos1);
             if (pos.Current.GetKind() == OperatorKind.Else) {
                 pos.Next();
                 break;
             }
             else if (pos.Current.GetKind() == OperatorKind.Elseif) {
                 if ((pos.Current as ElseifOperator).TestCondition()) {
                     pos.Next();
                     break;
                 }
                 pos1 = (pos.Current as ElseifOperator).NextPos;
             }
             else if (pos.Current.GetKind() == OperatorKind.Endif) {
                 pos.Next();
                 break;
             }
         }
     }
 }
Beispiel #2
0
        //****************************************************************************************************
		public void Execute(Subroutine.Moment pos) {
			int pos1 = m_nextpos;
			while (true) {
				pos.GoTo(pos1);
				if (pos.Current.GetKind() == OperatorKind.Elseif) {
					pos1 = (pos.Current as ElseifOperator).NextPos;
				}
				else if (pos.Current.GetKind() == OperatorKind.Else) {
					pos1 = (pos.Current as ElseOperator).NextPos;
				}
				else if (pos.Current.GetKind() == OperatorKind.Endif) {
					pos.Next();
					break;
				}
			}
		}
Beispiel #3
0
			private void Set(string name, Subroutine sub) {
				int sres = m_names.IndexOf(name);
				if (sres >= 0) {
					m_names.RemoveAt(sres);
					m_subs.RemoveAt(sres);
				}
				m_names.Add(name);
				m_subs.Add(sub);                
			}
Beispiel #4
0
			private bool LoadFile(FileInfo file) {
				try {
					StreamReader sr = file.OpenText();
					LinkedList ll = new LinkedList();
					try {
						while (sr.Peek() != -1) {
							ll.AddFirst(sr.ReadLine());
						}
					} finally {
						sr.Close();
					}
					string[] strs = new String[ll.Count];
					int i = 0;
					while (!ll.IsEmpty()) {
						strs[i] = (ll.RemoveLast() as String);
						i++;
					}
					Subroutine sub;
					try {
						sub = new Subroutine(strs, file.Name);                        
					} catch (LineSyntaxException ex) {
						InterprEnvironment.Instance.CurrentConsole.PrintLn(ex.Message + " в функции " + ex.Function + "[] в строке " + ex.Line);
						return false;
					} catch (SyntaxErrorException ex) {
                        InterprEnvironment.Instance.CurrentConsole.PrintLn(ex.Message + " в " + file.Name);
						return false;
					}                    
					Set(file.Name, sub);
				} catch {
                    throw new OtherException("ќшибка в методе Environment.Load()");
				}
				return true;
			}
Beispiel #5
0
			public Moment(Subroutine sub) {
				m_sub = sub;
				m_pos = 1;
				s_break = 0;
			}