public InstructionArgType this[int idx]
		{
			get
			{
				switch(idx)
				{
					case 0:
						return Arg1;
					case 1:
						return Arg2;
					case 2:
						return Arg3;
					default:
						throw new Exception("Invalid arg index!");
				}
			}
			set
			{
				switch(idx)
				{
					case 0:
						Arg1 = value;
						break;
					case 1:
						Arg2 = value;
						break;
					case 2:
						Arg3 = value;
						break;
					default:
						throw new Exception("Invalid arg index!");
				}
			}
		}
		public static void RegisterType(InstructionArgType tp)
		{
			if (TypeLookup.ContainsKey(tp.Name))
				throw new Exception("Duplicate arg type definition!");
			tp.ID = TypeLookup.Count;
			TypeLookup[tp.Name.ToUpper()] = tp;
		}
		/// <summary>
		/// This should be called on all values
		/// of this type. It initializes the class
		/// fields.
		/// </summary>
		public void Init()
		{
			Arg1 = InstructionArgType.None;
			Arg2 = InstructionArgType.None;
			Arg3 = InstructionArgType.None;
		}
示例#4
0
		public bool NeedsSizeArgument(InstructionArgType arg1Tp, InstructionArgType arg2Tp, InstructionArgType arg3Tp, ref List<byte> sizesNeeded, out bool constructorNeeded, ref List<string> formsNeeded)
		{
			constructorNeeded = true;
			if (arg1Tp == InstructionArgType.None)
				return false;
			int cnt = 0;
			int argChecking = -1;
			SizelessArgSet argSet = new SizelessArgSet()
			{
				Arg1 = arg1Tp.TrueSizelessType,
				Arg2 = arg2Tp.TrueSizelessType,
				Arg3 = arg3Tp.TrueSizelessType
			};
			if (ConstructorsEmitted.ContainsKey(argSet))
			{
				constructorNeeded = false;
				return false;
			}
			else
			{
				ConstructorsEmitted[argSet] = true;
				constructorNeeded = true;
			}
			InstructionForm curForm = null;
			foreach (InstructionForm f in FinalForms)
			{
				if (curForm == null && f.Arg1.ArgType == arg1Tp && f.Arg2.ArgType == arg2Tp && f.Arg3.ArgType == arg3Tp)
				{
					curForm = f;
				}
				else if (f.Arg1.ArgType.SizelessType == arg1Tp.SizelessType && f.Arg2.ArgType.SizelessType == arg2Tp.SizelessType && f.Arg3.ArgType.SizelessType == arg3Tp.SizelessType)
				{
					if (argChecking < 0)
					{
						if (f.Arg1.ArgType.Size != arg1Tp.Size)
						{
							argChecking = 0;
						}
						else if (f.Arg2.ArgType.Size != arg2Tp.Size)
						{
							argChecking = 1;
						}
						else if (f.Arg3.ArgType.Size != arg3Tp.Size)
						{
							argChecking = 2;
						}
						else
						{
							throw new Exception("Duplicate size!");
						}
					}
					cnt++;
					sizesNeeded.Add((byte)f[argChecking].ArgType.Size);
					formsNeeded.Add(f.GetInstructionCaseString());
				}
			}
			if (curForm == null)
				throw new Exception("Unable to locate this form!");
			if (argChecking >= 0)
			{
				cnt++;
				sizesNeeded.Add((byte)curForm[argChecking].ArgType.Size);
				formsNeeded.Add(curForm.GetInstructionCaseString());
			}
			return cnt > 1;
		}
		public CustomArgOperation(InstructionArgType parent, Token[] tokens)
		{
			this.toks = tokens;
			this.ParentArg = parent;
		}