public void AddRange(CodeParameterDeclarationExpression[] value)
		{
			if (value == null)
			{
				throw new ArgumentNullException("value");
			}

			for (int i = 0; i < value.Length; i++)
			{
				Add(value[i]);
			}
		}
		public CodeParameterDeclarationExpressionCollection(CodeParameterDeclarationExpression[] value)
		{
			AddRange(value);
		}
		//
		// Methods
		//
		public int Add(CodeParameterDeclarationExpression value)
		{
			return List.Add(value);
		}
		public void Insert(int index, CodeParameterDeclarationExpression value)
		{
			List.Insert(index, value);
		}
		public void Remove(CodeParameterDeclarationExpression value)
		{
			List.Remove(value);
		}
		public int IndexOf(CodeParameterDeclarationExpression value)
		{
			return List.IndexOf(value);
		}
		public void CopyTo(CodeParameterDeclarationExpression[] array, int index)
		{
			List.CopyTo(array, index);
		}
		public bool Contains(CodeParameterDeclarationExpression value)
		{
			return List.Contains(value);
		}
Пример #9
0
		protected override void GenerateParameterDeclarationExpression(CodeParameterDeclarationExpression e)
		{
			this.OutputDirection(e.Direction);
			this.OutputType(e.Type);
			base.Output.Write(' ');
			base.Output.Write(this.GetSafeName(e.Name));
		}
Пример #10
0
		public void WriteConstructors(CodeTypeDeclaration tdecl, string className)
		{
			if (ParentInstruction.LinesOfDocumentation.Count == 0)
			{
				ParentInstruction.LinesOfDocumentation.Add("Creates a new instance of the <see cref=\"" + ParentInstruction.FileName + "\" /> class.");
			}
			if (Arg1.ArgType == InstructionArgType.None)
			{
				CodeConstructor c = new CodeConstructor();
				c.Attributes = MemberAttributes.Public;

				c.Documentation.AddRange(
					new CodeDocumentationSummaryNode(ParentInstruction.LinesOfDocumentation),
					new CodeDocumentationParameterNode("parentAssembler", "The assembler to add this instruction to.")
				);
				c.Parameters.Add(new CodeParameterDeclarationExpression(StaticTypeReferences.Assembler, "parentAssembler"));
				c.BaseConstructorArgs.Add(new CodeArgumentReferenceExpression("parentAssembler"));
				tdecl.Members.Add(c);
			}
			else
			{
				List<byte> sizesNeeded = new List<byte>(4);
				List<string> formsNeeded = new List<string>(4);
				bool constructorNeeded;
				bool needsSizeArg = ParentInstruction.NeedsSizeArgument(Arg1.ArgType, Arg2.ArgType, Arg3.ArgType, ref sizesNeeded, out constructorNeeded, ref formsNeeded);
				if (constructorNeeded)
				{
					int segArgIdx;
					bool needsSegArg = NeedsSegment(out segArgIdx);
					CodeConstructor c = new CodeConstructor();
					c.Attributes = MemberAttributes.Public;
					c.Parameters.Add(new CodeParameterDeclarationExpression(StaticTypeReferences.Assembler, "parentAssembler"));
					c.BaseConstructorArgs.Add(new CodeArgumentReferenceExpression("parentAssembler"));
					Arg1.ArgType.RequestParameters(Arg1, needsSizeArg, c.Parameters);
					Arg2.ArgType.RequestParameters(Arg2, needsSizeArg, c.Parameters);
					Arg3.ArgType.RequestParameters(Arg3, needsSizeArg, c.Parameters);
					if (needsSizeArg)
						c.Parameters.Add(new CodeParameterDeclarationExpression(StaticTypeReferences.Byte, "size"));
					if (needsSegArg)
					{
						CodeParameterDeclarationExpression cpd = new CodeParameterDeclarationExpression(StaticTypeReferences.Segment, "segment");
						cpd.DefaultValueExpression = new CodeFieldReferenceExpression(StaticTypeReferences.SegmentExpression, DefaultSegment.ToString());
						c.Parameters.Add(cpd);
					}
						
					CodeDocumentationNodeCollection docs = new CodeDocumentationNodeCollection();
					docs.Add(new CodeDocumentationParameterNode("parentAssembler", "The assembler to add this instruction to."));
					Arg1.ArgType.AddDocumentationLines(Arg1.Name, docs);
					Arg2.ArgType.AddDocumentationLines(Arg2.Name, docs);
					Arg3.ArgType.AddDocumentationLines(Arg3.Name, docs);
					if (needsSizeArg)
						docs.Add(new CodeDocumentationParameterNode("size", "The size of the operands for this instruction."));
					if (needsSegArg)
						docs.Add(new CodeDocumentationParameterNode("segment", "The segment to use for memory access within this instruction."));
					c.Documentation.Add(new CodeDocumentationSummaryNode(ParentInstruction.LinesOfDocumentation));
					c.Documentation.AddRange(docs);
					WriteConstructorBodyInstructionFormDetermination(c, sizesNeeded, formsNeeded);
					Arg1.ArgType.WriteConstructorBodyArgProcessing(this, c, 0);
					Arg2.ArgType.WriteConstructorBodyArgProcessing(this, c, 1);
					Arg3.ArgType.WriteConstructorBodyArgProcessing(this, c, 2);
					if (needsSegArg)
					{
						c.Statements.Add(
							new CodeAssignStatement(
								new CodeFieldReferenceExpression(new CodeThisReferenceExpression(), GetArgName(FieldTypeRegistry.Segment.ID, 1, segArgIdx)),
								new CodeArgumentReferenceExpression("segment")
							)
						);
					}

					tdecl.Members.Add(c);
				}
			}
		}