Esempio n. 1
0
		public void AddRegister(string name, RegisterType type, idScriptParser parser, idWindow window, idWindowVariable var)
		{
			idRegister register = FindRegister(name);

			if(register == null)
			{
				int regCount = idRegister.RegisterTypeCount[(int) type];
				register = new idRegister(name, type, var);
				
				if(type == RegisterType.String)
				{
					idToken token;
					
					if((token = parser.ReadToken()) != null)
					{
						var.Init(idE.Language.Get(token.ToString()), window);
					}
				}
				else
				{
					for(int i = 0; i < regCount; i++)
					{
						register.Indexes[i] = window.ParseExpression(parser, null);

						if(i < (regCount - 1))
						{
							parser.ExpectTokenString(",");
						}
					}
				}

				_registers.Add(register);
				_registerDict.Add(name, register);
			}
			else
			{
				int regCount = idRegister.RegisterTypeCount[(int) type];

				register.Variable = var;

				if(type == RegisterType.String)
				{
					idToken token = parser.ReadToken();

					if(token != null)
					{
						var.Init(token.ToString(), window);
					}
				}
				else
				{
					for(int i = 0; i < regCount; i++)
					{
						register.Indexes[i] = window.ParseExpression(parser, null);

						if(i < (regCount - 1))
						{
							parser.ExpectTokenString(",");
						}
					}
				}
			}
		}