public override object Visit(IndexerDeclaration indexerDeclaration, object data)
        {
            DebugOutput(indexerDeclaration);

            AppendNewLine();
            AppendAttributes(indexerDeclaration.Attributes);
            AppendIndentation();
            sourceText.Append("Default ");
            sourceText.Append(GetModifier(indexerDeclaration.Modifier));
            sourceText.Append("Property Blubber(");
            AppendParameters(indexerDeclaration.Parameters);
            sourceText.Append(") As ");
            sourceText.Append(GetTypeString(indexerDeclaration.TypeReference));
            AppendNewLine();

            if (indexerDeclaration.GetRegion != null) {
                ++indentLevel;
                indexerDeclaration.GetRegion.AcceptVisitor(this, data);
                --indentLevel;
            }

            if (indexerDeclaration.SetRegion != null) {
                ++indentLevel;
                indexerDeclaration.SetRegion.AcceptVisitor(this, data);
                --indentLevel;
            }

            AppendIndentation();sourceText.Append("End Property");
            AppendNewLine();
            return null;
        }
 public override object Visit(IndexerDeclaration indexerDeclaration, object data)
 {
     return null;
 }
 public override object Visit(IndexerDeclaration indexerDeclaration, object data)
 {
     Console.WriteLine(indexerDeclaration.ToString());
     return indexerDeclaration.AcceptChildren(this, data);
 }
 public virtual object Visit(IndexerDeclaration indexerDeclaration, object data)
 {
     foreach (AttributeSection section in indexerDeclaration.Attributes) {
         section.AcceptVisitor(this, data);
     }
     foreach (ParameterDeclarationExpression p in indexerDeclaration.Parameters) {
         p.AcceptVisitor(this, data);
     }
     if (indexerDeclaration.HasGetRegion) {
         indexerDeclaration.GetRegion.AcceptVisitor(this, data);
     }
     if (indexerDeclaration.HasSetRegion) {
         indexerDeclaration.SetRegion.AcceptVisitor(this, data);
     }
     return data;
 }
Exemplo n.º 5
0
	void InterfaceMemberDecl() {

#line  1232 "cs.ATG" 
		TypeReference type;
		ArrayList p;
		AttributeSection section;
		Modifier mod = Modifier.None;
		ArrayList attributes = new ArrayList();
		ArrayList parameters = new ArrayList();
		string name;
		PropertyGetRegion getBlock;
		PropertySetRegion setBlock;
		Point startLocation = new Point(-1, -1);
		
		while (la.kind == 16) {
			AttributeSection(
#line  1244 "cs.ATG" 
out section);

#line  1244 "cs.ATG" 
			attributes.Add(section); 
		}
		if (la.kind == 88) {
			lexer.NextToken();

#line  1245 "cs.ATG" 
			mod = Modifier.New; startLocation = t.Location; 
		}
		if (
#line  1248 "cs.ATG" 
NotVoidPointer()) {
			Expect(122);

#line  1248 "cs.ATG" 
			if (startLocation.X == -1) startLocation = t.Location; 
			Expect(1);

#line  1248 "cs.ATG" 
			name = t.val; 
			Expect(18);
			if (StartOf(9)) {
				FormalParameterList(
#line  1249 "cs.ATG" 
out parameters);
			}
			Expect(19);
			Expect(10);

#line  1249 "cs.ATG" 
			MethodDeclaration md = new MethodDeclaration(name, mod, new TypeReference("void"), parameters, attributes);
			md.StartLocation = startLocation;
			md.EndLocation = t.EndLocation;
			compilationUnit.AddChild(md);
			
		} else if (StartOf(18)) {
			if (StartOf(8)) {
				Type(
#line  1255 "cs.ATG" 
out type);

#line  1255 "cs.ATG" 
				if (startLocation.X == -1) startLocation = t.Location; 
				if (la.kind == 1) {
					lexer.NextToken();

#line  1257 "cs.ATG" 
					name = t.val; Point qualIdentEndLocation = t.EndLocation; 
					if (la.kind == 18) {
						lexer.NextToken();
						if (StartOf(9)) {
							FormalParameterList(
#line  1260 "cs.ATG" 
out parameters);
						}
						Expect(19);
						Expect(10);

#line  1260 "cs.ATG" 
						MethodDeclaration md = new MethodDeclaration(name, mod, type, parameters, attributes);
						md.StartLocation = startLocation;
						md.EndLocation = t.EndLocation;
						compilationUnit.AddChild(md);
						
					} else if (la.kind == 14) {

#line  1266 "cs.ATG" 
						PropertyDeclaration pd = new PropertyDeclaration(name, type, mod, attributes); compilationUnit.AddChild(pd); 
						lexer.NextToken();

#line  1267 "cs.ATG" 
						Point bodyStart = t.Location;
						InterfaceAccessors(
#line  1267 "cs.ATG" 
out getBlock, out setBlock);
						Expect(15);

#line  1267 "cs.ATG" 
						pd.GetRegion = getBlock; pd.SetRegion = setBlock; pd.StartLocation = startLocation; pd.EndLocation = qualIdentEndLocation; pd.BodyStart = bodyStart; pd.BodyEnd = t.EndLocation; 
					} else SynErr(151);
				} else if (la.kind == 110) {
					lexer.NextToken();
					Expect(16);
					FormalParameterList(
#line  1270 "cs.ATG" 
out p);
					Expect(17);

#line  1270 "cs.ATG" 
					Point bracketEndLocation = t.EndLocation; 

#line  1270 "cs.ATG" 
					IndexerDeclaration id = new IndexerDeclaration(type, p, mod, attributes); compilationUnit.AddChild(id); 
					Expect(14);

#line  1271 "cs.ATG" 
					Point bodyStart = t.Location;
					InterfaceAccessors(
#line  1271 "cs.ATG" 
out getBlock, out setBlock);
					Expect(15);

#line  1271 "cs.ATG" 
					id.GetRegion = getBlock; id.SetRegion = setBlock; id.StartLocation = startLocation;  id.EndLocation = bracketEndLocation; id.BodyStart = bodyStart; id.BodyEnd = t.EndLocation;
				} else SynErr(152);
			} else {
				lexer.NextToken();

#line  1274 "cs.ATG" 
				if (startLocation.X == -1) startLocation = t.Location; 
				Type(
#line  1274 "cs.ATG" 
out type);
				Expect(1);

#line  1274 "cs.ATG" 
				EventDeclaration ed = new EventDeclaration(type, t.val, mod, attributes);
				compilationUnit.AddChild(ed);
				
				Expect(10);

#line  1277 "cs.ATG" 
				ed.StartLocation = startLocation; ed.EndLocation = t.EndLocation; 
			}
		} else SynErr(153);
	}
Exemplo n.º 6
0
	void StructMemberDecl(
#line  1005 "cs.ATG" 
Modifiers m, ArrayList attributes) {

#line  1007 "cs.ATG" 
		string qualident = null;
		TypeReference type;
		Expression expr;
		ArrayList p = new ArrayList();
		Statement stmt = null;
		ArrayList variableDeclarators = new ArrayList();
		
		if (la.kind == 59) {

#line  1015 "cs.ATG" 
			m.Check(Modifier.Constants); 
			lexer.NextToken();
			Type(
#line  1017 "cs.ATG" 
out type);
			Expect(1);

#line  1017 "cs.ATG" 
			FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier | Modifier.Const);
			VariableDeclaration f = new VariableDeclaration(t.val);
			fd.Fields.Add(f);
			
			Expect(3);
			Expr(
#line  1021 "cs.ATG" 
out expr);

#line  1021 "cs.ATG" 
			f.Initializer = expr; 
			while (la.kind == 12) {
				lexer.NextToken();
				Expect(1);

#line  1022 "cs.ATG" 
				f = new VariableDeclaration(t.val);
				fd.Fields.Add(f);
				
				Expect(3);
				Expr(
#line  1025 "cs.ATG" 
out expr);

#line  1025 "cs.ATG" 
				f.Initializer = expr; 
			}
			Expect(10);

#line  1026 "cs.ATG" 
			fd.EndLocation = t.EndLocation; compilationUnit.AddChild(fd); 
		} else if (
#line  1029 "cs.ATG" 
NotVoidPointer()) {

#line  1029 "cs.ATG" 
			m.Check(Modifier.PropertysEventsMethods); 
			Expect(122);

#line  1030 "cs.ATG" 
			Point startPos = t.Location; 
			Qualident(
#line  1031 "cs.ATG" 
out qualident);
			Expect(18);
			if (StartOf(9)) {
				FormalParameterList(
#line  1032 "cs.ATG" 
out p);
			}
			Expect(19);

#line  1032 "cs.ATG" 
			MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, 
			                                                           m.Modifier, 
			                                                           new TypeReference("void"), 
			                                                           p, 
			                                                           attributes);
			methodDeclaration.StartLocation = startPos;
			methodDeclaration.EndLocation   = t.EndLocation;
			compilationUnit.AddChild(methodDeclaration);
			compilationUnit.BlockStart(methodDeclaration);
			
			if (la.kind == 14) {
				Block(
#line  1042 "cs.ATG" 
out stmt);
			} else if (la.kind == 10) {
				lexer.NextToken();
			} else SynErr(141);

#line  1042 "cs.ATG" 
			compilationUnit.BlockEnd();
			methodDeclaration.Body  = (BlockStatement)stmt;
			
		} else if (la.kind == 68) {

#line  1046 "cs.ATG" 
			m.Check(Modifier.PropertysEventsMethods); 
			lexer.NextToken();

#line  1047 "cs.ATG" 
			EventDeclaration eventDecl = new EventDeclaration(m.Modifier, attributes);
			eventDecl.StartLocation = t.Location;
			compilationUnit.AddChild(eventDecl);
			compilationUnit.BlockStart(eventDecl);
			EventAddRegion addBlock = null;
			EventRemoveRegion removeBlock = null;
			
			Type(
#line  1054 "cs.ATG" 
out type);

#line  1054 "cs.ATG" 
			eventDecl.TypeReference = type; 
			if (
#line  1056 "cs.ATG" 
IsVarDecl()) {
				VariableDeclarator(
#line  1056 "cs.ATG" 
variableDeclarators);
				while (la.kind == 12) {
					lexer.NextToken();
					VariableDeclarator(
#line  1057 "cs.ATG" 
variableDeclarators);
				}
				Expect(10);

#line  1057 "cs.ATG" 
				eventDecl.VariableDeclarators = variableDeclarators; eventDecl.EndLocation = t.EndLocation;  
			} else if (la.kind == 1) {
				Qualident(
#line  1058 "cs.ATG" 
out qualident);

#line  1058 "cs.ATG" 
				eventDecl.Name = qualident; eventDecl.EndLocation = t.EndLocation;  
				Expect(14);

#line  1059 "cs.ATG" 
				eventDecl.BodyStart = t.Location; 
				EventAccessorDecls(
#line  1060 "cs.ATG" 
out addBlock, out removeBlock);
				Expect(15);

#line  1061 "cs.ATG" 
				eventDecl.BodyEnd   = t.EndLocation; 
			} else SynErr(142);

#line  1062 "cs.ATG" 
			compilationUnit.BlockEnd();
				                                           eventDecl.AddRegion = addBlock;
			eventDecl.RemoveRegion = removeBlock;
			
		} else if (
#line  1069 "cs.ATG" 
IdentAndLPar()) {

#line  1069 "cs.ATG" 
			m.Check(Modifier.Constructors | Modifier.StaticConstructors); 
			Expect(1);

#line  1070 "cs.ATG" 
			string name = t.val; Point startPos = t.Location; 
			Expect(18);
			if (StartOf(9)) {

#line  1070 "cs.ATG" 
				m.Check(Modifier.Constructors); 
				FormalParameterList(
#line  1071 "cs.ATG" 
out p);
			}
			Expect(19);

#line  1073 "cs.ATG" 
			ConstructorInitializer init = null;  
			if (la.kind == 9) {

#line  1074 "cs.ATG" 
				m.Check(Modifier.Constructors); 
				ConstructorInitializer(
#line  1075 "cs.ATG" 
out init);
			}

#line  1077 "cs.ATG" 
			ConstructorDeclaration cd = new ConstructorDeclaration(name, m.Modifier, p, init, attributes); 
			cd.StartLocation = startPos;
			cd.EndLocation   = t.EndLocation;
			
			if (la.kind == 14) {
				Block(
#line  1082 "cs.ATG" 
out stmt);
			} else if (la.kind == 10) {
				lexer.NextToken();
			} else SynErr(143);

#line  1082 "cs.ATG" 
			cd.Body = (BlockStatement)stmt; compilationUnit.AddChild(cd); 
		} else if (la.kind == 69 || la.kind == 79) {

#line  1085 "cs.ATG" 
			m.Check(Modifier.Operators);
			if (m.isNone) Error("at least one modifier must be set"); 
			bool isImplicit = true;
			
			if (la.kind == 79) {
				lexer.NextToken();
			} else {
				lexer.NextToken();

#line  1089 "cs.ATG" 
				isImplicit = false; 
			}
			Expect(91);
			Type(
#line  1090 "cs.ATG" 
out type);

#line  1090 "cs.ATG" 
			TypeReference operatorType = type; 
			Expect(18);
			Type(
#line  1091 "cs.ATG" 
out type);
			Expect(1);

#line  1091 "cs.ATG" 
			string varName = t.val; 
			Expect(19);
			if (la.kind == 14) {
				Block(
#line  1091 "cs.ATG" 
out stmt);
			} else if (la.kind == 10) {
				lexer.NextToken();

#line  1091 "cs.ATG" 
				stmt = null; 
			} else SynErr(144);

#line  1094 "cs.ATG" 
			OperatorDeclarator operatorDeclarator = new OperatorDeclarator(isImplicit ? OperatorType.Implicit : OperatorType.Explicit,
			                                                              operatorType,
			                                                              type,
			                                                              varName);
			OperatorDeclaration operatorDeclaration = new OperatorDeclaration(operatorDeclarator, m.Modifier, attributes);
			operatorDeclaration.Body = stmt;
			compilationUnit.AddChild(operatorDeclaration);
			
		} else if (StartOf(17)) {

#line  1104 "cs.ATG" 
			bool partial = false; 
			if (
#line  1105 "cs.ATG" 
IdentIsPartial ()) {
				lexer.NextToken();

#line  1105 "cs.ATG" 
				partial = true; 
			}
			TypeDecl(
#line  1106 "cs.ATG" 
m, attributes, partial);
		} else if (StartOf(8)) {
			Type(
#line  1107 "cs.ATG" 
out type);

#line  1107 "cs.ATG" 
			Point startPos = t.Location; 
			if (la.kind == 91) {

#line  1109 "cs.ATG" 
				Token op;
				m.Check(Modifier.Operators);
				if (m.isNone) Error("at least one modifier must be set");
				
				lexer.NextToken();
				OverloadableOperator(
#line  1113 "cs.ATG" 
out op);

#line  1113 "cs.ATG" 
				TypeReference firstType, secondType = null; string secondName = null; 
				Expect(18);
				Type(
#line  1114 "cs.ATG" 
out firstType);
				Expect(1);

#line  1114 "cs.ATG" 
				string firstName = t.val; 
				if (la.kind == 12) {
					lexer.NextToken();
					Type(
#line  1115 "cs.ATG" 
out secondType);
					Expect(1);

#line  1115 "cs.ATG" 
					secondName = t.val; 

#line  1115 "cs.ATG" 
					if (ParserUtil.IsUnaryOperator(op) && !ParserUtil.IsBinaryOperator(op))
					Error("too many operands for unary operator"); 
					
				} else if (la.kind == 19) {

#line  1118 "cs.ATG" 
					if (ParserUtil.IsBinaryOperator(op))
					Error("too few operands for binary operator");
					
				} else SynErr(145);
				Expect(19);
				if (la.kind == 14) {
					Block(
#line  1122 "cs.ATG" 
out stmt);
				} else if (la.kind == 10) {
					lexer.NextToken();
				} else SynErr(146);

#line  1124 "cs.ATG" 
				OperatorDeclarator operatorDeclarator = new OperatorDeclarator(secondType != null ? OperatorType.Binary : OperatorType.Unary, 
				                                                              type,
				                                                              op.kind,
				                                                              firstType,
				                                                              firstName,
				                                                              secondType,
				                                                              secondName);
				OperatorDeclaration operatorDeclaration = new OperatorDeclaration(operatorDeclarator, m.Modifier, attributes);
				operatorDeclaration.Body = stmt;
				compilationUnit.AddChild(operatorDeclaration);
				
			} else if (
#line  1137 "cs.ATG" 
IsVarDecl()) {

#line  1137 "cs.ATG" 
				m.Check(Modifier.Fields); 
				FieldDeclaration fd = new FieldDeclaration(attributes, type, m.Modifier);
				fd.StartLocation = startPos; 
				
				VariableDeclarator(
#line  1141 "cs.ATG" 
variableDeclarators);
				while (la.kind == 12) {
					lexer.NextToken();
					VariableDeclarator(
#line  1142 "cs.ATG" 
variableDeclarators);
				}
				Expect(10);

#line  1143 "cs.ATG" 
				fd.EndLocation = t.EndLocation; fd.Fields = variableDeclarators; compilationUnit.AddChild(fd); 
			} else if (la.kind == 110) {

#line  1146 "cs.ATG" 
				m.Check(Modifier.Indexers); 
				lexer.NextToken();
				Expect(16);
				FormalParameterList(
#line  1147 "cs.ATG" 
out p);
				Expect(17);

#line  1147 "cs.ATG" 
				Point endLocation = t.EndLocation; 
				Expect(14);

#line  1148 "cs.ATG" 
				IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes);
				indexer.StartLocation = startPos;
				indexer.EndLocation   = endLocation;
				indexer.BodyStart     = t.Location;
				PropertyGetRegion getRegion;
				PropertySetRegion setRegion;
				
				AccessorDecls(
#line  1155 "cs.ATG" 
out getRegion, out setRegion);
				Expect(15);

#line  1156 "cs.ATG" 
				indexer.BodyEnd    = t.EndLocation;
				indexer.GetRegion = getRegion;
				indexer.SetRegion = setRegion;
				compilationUnit.AddChild(indexer);
				
			} else if (la.kind == 1) {
				Qualident(
#line  1161 "cs.ATG" 
out qualident);

#line  1161 "cs.ATG" 
				Point qualIdentEndLocation = t.EndLocation; 
				if (la.kind == 14 || la.kind == 18) {
					if (la.kind == 18) {

#line  1164 "cs.ATG" 
						m.Check(Modifier.PropertysEventsMethods); 
						lexer.NextToken();
						if (StartOf(9)) {
							FormalParameterList(
#line  1165 "cs.ATG" 
out p);
						}
						Expect(19);

#line  1165 "cs.ATG" 
						MethodDeclaration methodDeclaration = new MethodDeclaration(qualident, 
						                                                     m.Modifier, 
						                                                     type, 
						                                                     p, 
						                                                     attributes);
						     methodDeclaration.StartLocation = startPos;
						     methodDeclaration.EndLocation   = t.EndLocation;
						     compilationUnit.AddChild(methodDeclaration);
						  
						if (la.kind == 14) {
							Block(
#line  1174 "cs.ATG" 
out stmt);
						} else if (la.kind == 10) {
							lexer.NextToken();
						} else SynErr(147);

#line  1174 "cs.ATG" 
						methodDeclaration.Body  = (BlockStatement)stmt; 
					} else {
						lexer.NextToken();

#line  1177 "cs.ATG" 
						PropertyDeclaration pDecl = new PropertyDeclaration(qualident, type, m.Modifier, attributes); 
						pDecl.StartLocation = startPos;
						pDecl.EndLocation   = qualIdentEndLocation;
						pDecl.BodyStart   = t.Location;
						PropertyGetRegion getRegion;
						PropertySetRegion setRegion;
						
						AccessorDecls(
#line  1184 "cs.ATG" 
out getRegion, out setRegion);
						Expect(15);

#line  1186 "cs.ATG" 
						pDecl.GetRegion = getRegion;
						pDecl.SetRegion = setRegion;
						pDecl.BodyEnd = t.EndLocation;
						compilationUnit.AddChild(pDecl);
						
					}
				} else if (la.kind == 13) {

#line  1194 "cs.ATG" 
					m.Check(Modifier.Indexers); 
					lexer.NextToken();
					Expect(110);
					Expect(16);
					FormalParameterList(
#line  1195 "cs.ATG" 
out p);
					Expect(17);

#line  1196 "cs.ATG" 
					IndexerDeclaration indexer = new IndexerDeclaration(type, p, m.Modifier, attributes);
					indexer.StartLocation = startPos;
					indexer.EndLocation   = t.EndLocation;
					indexer.NamespaceName = qualident;
					PropertyGetRegion getRegion;
					PropertySetRegion setRegion;
					
					Expect(14);

#line  1203 "cs.ATG" 
					Point bodyStart = t.Location; 
					AccessorDecls(
#line  1204 "cs.ATG" 
out getRegion, out setRegion);
					Expect(15);

#line  1205 "cs.ATG" 
					indexer.BodyStart = bodyStart;
					indexer.BodyEnd   = t.EndLocation;
					indexer.GetRegion = getRegion;
					indexer.SetRegion = setRegion;
					compilationUnit.AddChild(indexer);
					
				} else SynErr(148);
			} else SynErr(149);
		} else SynErr(150);
	}
 public override object Visit(IndexerDeclaration indexerDeclaration, object data)
 {
     VisitAttributes(indexerDeclaration.Attributes, data);
     outputFormatter.Indent();
     VisitModifier(indexerDeclaration.Modifier);
     Visit(indexerDeclaration.TypeReference, data);
     outputFormatter.Space();
     if (indexerDeclaration.NamespaceName != null && indexerDeclaration.NamespaceName.Length > 0) {
         outputFormatter.PrintIdentifier(indexerDeclaration.NamespaceName);
         outputFormatter.PrintToken(Tokens.Dot);
     }
     outputFormatter.PrintToken(Tokens.This);
     outputFormatter.PrintToken(Tokens.OpenSquareBracket);
     AppendCommaSeparatedList(indexerDeclaration.Parameters);
     outputFormatter.PrintToken(Tokens.CloseSquareBracket);
     outputFormatter.NewLine();
     outputFormatter.Indent();
     outputFormatter.PrintToken(Tokens.OpenCurlyBrace);
     outputFormatter.NewLine();
     ++outputFormatter.IndentationLevel;
     if (indexerDeclaration.GetRegion != null) {
         indexerDeclaration.GetRegion.AcceptVisitor(this, data);
     }
     if (indexerDeclaration.SetRegion != null) {
         indexerDeclaration.SetRegion.AcceptVisitor(this, data);
     }
     --outputFormatter.IndentationLevel;
     outputFormatter.Indent();
     outputFormatter.PrintToken(Tokens.CloseCurlyBrace);
     outputFormatter.NewLine();
     return null;
 }