Esempio n. 1
0
		public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
		{
			Push();
			object result = base.VisitTypeDeclaration(typeDeclaration, data);
			Pop();
			return result;
		}
		public virtual object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) {
			throw new global::System.NotImplementedException("TypeDeclaration");
		}
Esempio n. 3
0
		public virtual object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) {
			Debug.Assert((typeDeclaration != null));
			Debug.Assert((typeDeclaration.Attributes != null));
			Debug.Assert((typeDeclaration.BaseTypes != null));
			Debug.Assert((typeDeclaration.Templates != null));
			foreach (AttributeSection o in typeDeclaration.Attributes) {
				Debug.Assert(o != null);
				o.AcceptVisitor(this, data);
			}
			foreach (TypeReference o in typeDeclaration.BaseTypes) {
				Debug.Assert(o != null);
				o.AcceptVisitor(this, data);
			}
			foreach (TemplateDefinition o in typeDeclaration.Templates) {
				Debug.Assert(o != null);
				o.AcceptVisitor(this, data);
			}
			return typeDeclaration.AcceptChildren(this, data);
		}
Esempio n. 4
0
	void InterfaceBody(TypeDeclaration newType) {
		while (la.kind == 1 || la.kind == 21) {
			EndOfStmt();
		}
		while (StartOf(15)) {
			InterfaceMemberDecl();
			while (la.kind == 1 || la.kind == 21) {
				EndOfStmt();
			}
		}
		Expect(113);
		Expect(142);
		newType.EndLocation = t.EndLocation;
		EndOfStmt();
	}
		public virtual object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) {
			Debug.Assert((typeDeclaration != null));
			Debug.Assert((typeDeclaration.Attributes != null));
			Debug.Assert((typeDeclaration.BaseTypes != null));
			Debug.Assert((typeDeclaration.Templates != null));
			for (int i = 0; i < typeDeclaration.Attributes.Count; i++) {
				AttributeSection o = typeDeclaration.Attributes[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (AttributeSection)nodeStack.Pop();
				if (o == null)
					typeDeclaration.Attributes.RemoveAt(i--);
				else
					typeDeclaration.Attributes[i] = o;
			}
			for (int i = 0; i < typeDeclaration.BaseTypes.Count; i++) {
				TypeReference o = typeDeclaration.BaseTypes[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (TypeReference)nodeStack.Pop();
				if (o == null)
					typeDeclaration.BaseTypes.RemoveAt(i--);
				else
					typeDeclaration.BaseTypes[i] = o;
			}
			for (int i = 0; i < typeDeclaration.Templates.Count; i++) {
				TemplateDefinition o = typeDeclaration.Templates[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (TemplateDefinition)nodeStack.Pop();
				if (o == null)
					typeDeclaration.Templates.RemoveAt(i--);
				else
					typeDeclaration.Templates[i] = o;
			}
			for (int i = 0; i < typeDeclaration.Children.Count; i++) {
				INode o = typeDeclaration.Children[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = nodeStack.Pop();
				if (o == null)
					typeDeclaration.Children.RemoveAt(i--);
				else
					typeDeclaration.Children[i] = o;
			}
			return null;
		}
Esempio n. 6
0
	void StructureBody(TypeDeclaration newType) {
		AttributeSection section;
		while (la.kind == 1 || la.kind == 21) {
			EndOfStmt();
		}
		while (StartOf(10)) {
			List<AttributeSection> attributes = new List<AttributeSection>();
				ModifierList m = new ModifierList();

			while (la.kind == 40) {
				AttributeSection(out section);
				attributes.Add(section);
			}
			while (StartOf(11)) {
				MemberModifier(m);
			}
			StructureMemberDecl(m, attributes);
			while (la.kind == 1 || la.kind == 21) {
				EndOfStmt();
			}
		}
		Expect(113);
		Expect(209);
		newType.EndLocation = t.EndLocation;
		EndOfStmt();
	}
Esempio n. 7
0
	void EnumBody(TypeDeclaration newType) {
		FieldDeclaration f;
		while (la.kind == 1 || la.kind == 21) {
			EndOfStmt();
		}
		while (StartOf(14)) {
			EnumMemberDecl(out f);
			AddChild(f);

			while (la.kind == 1 || la.kind == 21) {
				EndOfStmt();
			}
		}
		Expect(113);
		Expect(115);
		newType.EndLocation = t.EndLocation;
		EndOfStmt();
	}
Esempio n. 8
0
	void ClassBody(TypeDeclaration newType) {
		AttributeSection section;
		while (la.kind == 1 || la.kind == 21) {
			EndOfStmt();
		}
		while (StartOf(10)) {
			List<AttributeSection> attributes = new List<AttributeSection>();
				ModifierList m = new ModifierList();

			while (la.kind == 40) {
				AttributeSection(out section);
				attributes.Add(section);
			}
			while (StartOf(11)) {
				MemberModifier(m);
			}
			ClassMemberDecl(m, attributes);
			while (la.kind == 1 || la.kind == 21) {
				EndOfStmt();
			}
		}
	}
Esempio n. 9
0
	void NonModuleDeclaration(ModifierList m, List<AttributeSection> attributes) {
		TypeReference typeRef = null;
		List<TypeReference> baseInterfaces = null;

		switch (la.kind) {
		case 84: {
			m.Check(Modifiers.Classes);
			Get();
			TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
				newType.StartLocation = t.Location;
				AddChild(newType);
				BlockStart(newType);
				
				newType.Type       = ClassType.Class;

			Identifier();
			newType.Name = t.val;
			TypeParameterList(newType.Templates);
			EndOfStmt();
			newType.BodyStartLocation = t.Location;
			if (la.kind == 140) {
				ClassBaseType(out typeRef);
				SafeAdd(newType, newType.BaseTypes, typeRef);
			}
			while (la.kind == 136) {
				TypeImplementsClause(out baseInterfaces);
				newType.BaseTypes.AddRange(baseInterfaces);
			}
			ClassBody(newType);
			Expect(113);
			Expect(84);
			newType.EndLocation = t.EndLocation;
			EndOfStmt();
			BlockEnd();

			break;
		}
		case 155: {
			Get();
			m.Check(Modifiers.VBModules);
				TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
				AddChild(newType);
				BlockStart(newType);
				newType.StartLocation = m.GetDeclarationLocation(t.Location);
				newType.Type = ClassType.Module;

			Identifier();
			newType.Name = t.val;
			EndOfStmt();
			newType.BodyStartLocation = t.Location;
			ModuleBody(newType);
			BlockEnd();

			break;
		}
		case 209: {
			Get();
			m.Check(Modifiers.VBStructures);
				TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
				AddChild(newType);
				BlockStart(newType);
				newType.StartLocation = m.GetDeclarationLocation(t.Location);
				newType.Type = ClassType.Struct;

			Identifier();
			newType.Name = t.val;
			TypeParameterList(newType.Templates);
			EndOfStmt();
			newType.BodyStartLocation = t.Location;
			while (la.kind == 136) {
				TypeImplementsClause(out baseInterfaces);
				newType.BaseTypes.AddRange(baseInterfaces);
			}
			StructureBody(newType);
			BlockEnd();

			break;
		}
		case 115: {
			Get();
			m.Check(Modifiers.VBEnums);
				TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
				newType.StartLocation = m.GetDeclarationLocation(t.Location);
				AddChild(newType);
				BlockStart(newType);
				
				newType.Type = ClassType.Enum;

			Identifier();
			newType.Name = t.val;
			if (la.kind == 63) {
				Get();
				NonArrayTypeName(out typeRef, false);
				SafeAdd(newType, newType.BaseTypes, typeRef);
			}
			EndOfStmt();
			newType.BodyStartLocation = t.Location;
			EnumBody(newType);
			BlockEnd();

			break;
		}
		case 142: {
			Get();
			m.Check(Modifiers.VBInterfacs);
				TypeDeclaration newType = new TypeDeclaration(m.Modifier, attributes);
				newType.StartLocation = m.GetDeclarationLocation(t.Location);
				AddChild(newType);
				BlockStart(newType);
				newType.Type = ClassType.Interface;

			Identifier();
			newType.Name = t.val;
			TypeParameterList(newType.Templates);
			EndOfStmt();
			newType.BodyStartLocation = t.Location;
			while (la.kind == 140) {
				InterfaceBase(out baseInterfaces);
				newType.BaseTypes.AddRange(baseInterfaces);
			}
			InterfaceBody(newType);
			BlockEnd();

			break;
		}
		case 103: {
			Get();
			m.Check(Modifiers.VBDelegates);
				DelegateDeclaration delegateDeclr = new DelegateDeclaration(m.Modifier, attributes);
				delegateDeclr.ReturnType = new TypeReference("System.Void", true);
				delegateDeclr.StartLocation = m.GetDeclarationLocation(t.Location);
				List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();

			if (la.kind == 210) {
				Get();
				Identifier();
				delegateDeclr.Name = t.val;
				TypeParameterList(delegateDeclr.Templates);
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
					delegateDeclr.Parameters = p;
				}
			} else if (la.kind == 127) {
				Get();
				Identifier();
				delegateDeclr.Name = t.val;
				TypeParameterList(delegateDeclr.Templates);
				if (la.kind == 37) {
					Get();
					if (StartOf(7)) {
						FormalParameterList(p);
					}
					Expect(38);
					delegateDeclr.Parameters = p;
				}
				if (la.kind == 63) {
					Get();
					TypeReference type;
					TypeName(out type);
					delegateDeclr.ReturnType = type;
				}
			} else SynErr(251);
			delegateDeclr.EndLocation = t.EndLocation;
			EndOfStmt();
			AddChild(delegateDeclr);

			break;
		}
		default: SynErr(252); break;
		}
	}
		public sealed override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) {
			this.BeginVisit(typeDeclaration);
			object result = this.TrackedVisitTypeDeclaration(typeDeclaration, data);
			this.EndVisit(typeDeclaration);
			return result;
		}
		public virtual object TrackedVisitTypeDeclaration(TypeDeclaration typeDeclaration, object data) {
			return base.VisitTypeDeclaration(typeDeclaration, data);
		}
Esempio n. 12
0
		public override object VisitTypeDeclaration(TypeDeclaration typeDeclaration, object data)
		{
			TypeDeclaration oldTypeDeclaration = currentTypeDeclaration;
			this.currentTypeDeclaration = typeDeclaration;
			CodeTypeDeclaration codeTypeDeclaration = new CodeTypeDeclaration(typeDeclaration.Name);
			codeTypeDeclaration.TypeAttributes = ConvTypeAttributes(typeDeclaration.Modifier);
			codeTypeDeclaration.IsClass     = typeDeclaration.Type == ClassType.Class;
			codeTypeDeclaration.IsEnum      = typeDeclaration.Type == ClassType.Enum;
			codeTypeDeclaration.IsInterface = typeDeclaration.Type == ClassType.Interface;
			codeTypeDeclaration.IsStruct    = typeDeclaration.Type == ClassType.Struct;
			codeTypeDeclaration.IsPartial = (typeDeclaration.Modifier & Modifiers.Partial) != 0;
			
			if (typeDeclaration.BaseTypes != null) {
				foreach (TypeReference typeRef in typeDeclaration.BaseTypes) {
					codeTypeDeclaration.BaseTypes.Add(ConvType(typeRef));
				}
			}
			
			typeDeclarations.Push(codeTypeDeclaration);
			typeDeclaration.AcceptChildren(this, data);
			typeDeclarations.Pop();
			
			if (typeDeclarations.Count > 0) {
				typeDeclarations.Peek().Members.Add(codeTypeDeclaration);
			} else {
				namespaceDeclarations.Peek().Types.Add(codeTypeDeclaration);
			}
			currentTypeDeclaration = oldTypeDeclaration;
			
			return null;
		}