public override object Visit(LocalVariableDeclaration localVariableDeclaration, object data)
 {
     foreach (VariableDeclaration varDecl in localVariableDeclaration.Variables) {
         AddVariable(localVariableDeclaration.Type,
                     varDecl.Name,
                     localVariableDeclaration.StartLocation,
                     CurrentBlock == null ? new Point(-1, -1) : CurrentBlock.EndLocation);
     }
     return data;
 }
        public override object Visit(LocalVariableDeclaration localVariableDeclaration, object data)
        {
            CodeVariableDeclarationStatement declStmt = null;

            CodeTypeReference type = new CodeTypeReference(Convert(localVariableDeclaration.Type));

            foreach (VariableDeclaration var in localVariableDeclaration.Variables) {
                if (var.Initializer != null) {
                    declStmt = new CodeVariableDeclarationStatement(type,
                                                                 var.Name,
                                                                 (CodeExpression)((INode)var.Initializer).AcceptVisitor(this, data));
                } else {
                    declStmt = new CodeVariableDeclarationStatement(type,
                                                                 var.Name);
                }
            }

            AddStmt(declStmt);

            return declStmt;
        }
 public override object Visit(LocalVariableDeclaration localVariableDeclaration, object data)
 {
     Console.WriteLine(localVariableDeclaration.ToString());
     return localVariableDeclaration.AcceptChildren(this, data);
 }
 public override object Visit(LocalVariableDeclaration localVariableDeclaration, object data)
 {
     DebugOutput(localVariableDeclaration);
     foreach (VariableDeclaration localVar in localVariableDeclaration.Variables) {
         AppendIndentation();sourceText.Append(GetModifier(localVariableDeclaration.Modifier));
         ArrayCreateExpression ace = localVar.Initializer as ArrayCreateExpression;
         if (ace != null && (ace.ArrayInitializer == null || ace.ArrayInitializer.CreateExpressions == null)) {
             string arrayParameters  = String.Empty;
             foreach (Expression expr in ace.Parameters) {
                 arrayParameters += "(";
                 arrayParameters += expr.AcceptVisitor(this, data);
                 arrayParameters += " - 1)";
             }
             sourceText.Append("Dim ");
             sourceText.Append(localVar.Name);
             sourceText.Append(arrayParameters);
             sourceText.Append(" As ");
             sourceText.Append(ConvertTypeString(ace.CreateType.Type));
         } else {
             sourceText.Append("Dim ");
             sourceText.Append(localVar.Name);
             sourceText.Append(" As ");
             sourceText.Append(GetTypeString(localVariableDeclaration.Type));
             if (localVar.Initializer != null) {
                 sourceText.Append(" = ");
                 sourceText.Append(localVar.Initializer.AcceptVisitor(this, data).ToString());
             }
         }
         AppendNewLine();
     }
     return null;
 }
 public void AddToLookUpTable(LocalVariableDeclaration v)
 {
     v.Block = (INode)blockStack.Peek();
     lookUpTable.Add(v);
 }
 public virtual object Visit(LocalVariableDeclaration localVariableDeclaration, object data)
 {
     foreach (VariableDeclaration decl in localVariableDeclaration.Variables) {
         decl.AcceptVisitor(this, data);
     }
     return data;
 }
Example #7
0
	void LocalVariableDecl(
#line  1514 "cs.ATG" 
out Statement stmt) {

#line  1516 "cs.ATG" 
		TypeReference type;
		VariableDeclaration      var = null;
		LocalVariableDeclaration localVariableDeclaration; 
		
		Type(
#line  1521 "cs.ATG" 
out type);

#line  1521 "cs.ATG" 
		localVariableDeclaration = new LocalVariableDeclaration(type); localVariableDeclaration.StartLocation = t.Location; 
		LocalVariableDeclarator(
#line  1522 "cs.ATG" 
out var);

#line  1522 "cs.ATG" 
		localVariableDeclaration.Variables.Add(var); 
		while (la.kind == 12) {
			lexer.NextToken();
			LocalVariableDeclarator(
#line  1523 "cs.ATG" 
out var);

#line  1523 "cs.ATG" 
			localVariableDeclaration.Variables.Add(var); 
		}

#line  1524 "cs.ATG" 
		stmt = localVariableDeclaration; 
	}
Example #8
0
	void Statement() {

#line  1542 "cs.ATG" 
		TypeReference type;
		Expression expr;
		Statement stmt;
		
		if (
#line  1548 "cs.ATG" 
IsLabel()) {
			Expect(1);

#line  1548 "cs.ATG" 
			compilationUnit.AddChild(new LabelStatement(t.val)); 
			Expect(9);
			Statement();
		} else if (la.kind == 59) {
			lexer.NextToken();
			Type(
#line  1551 "cs.ATG" 
out type);

#line  1551 "cs.ATG" 
			LocalVariableDeclaration var = new LocalVariableDeclaration(type, Modifier.Const); string ident = null; var.StartLocation = t.Location; 
			Expect(1);

#line  1552 "cs.ATG" 
			ident = t.val; 
			Expect(3);
			Expr(
#line  1553 "cs.ATG" 
out expr);

#line  1553 "cs.ATG" 
			var.Variables.Add(new VariableDeclaration(ident, expr)); 
			while (la.kind == 12) {
				lexer.NextToken();
				Expect(1);

#line  1554 "cs.ATG" 
				ident = t.val; 
				Expect(3);
				Expr(
#line  1554 "cs.ATG" 
out expr);

#line  1554 "cs.ATG" 
				var.Variables.Add(new VariableDeclaration(ident, expr)); 
			}
			Expect(10);

#line  1555 "cs.ATG" 
			compilationUnit.AddChild(var); 
		} else if (
#line  1557 "cs.ATG" 
IsLocalVarDecl()) {
			LocalVariableDecl(
#line  1557 "cs.ATG" 
out stmt);
			Expect(10);

#line  1557 "cs.ATG" 
			compilationUnit.AddChild(stmt); 
		} else if (StartOf(24)) {
			EmbeddedStatement(
#line  1558 "cs.ATG" 
out stmt);

#line  1558 "cs.ATG" 
			compilationUnit.AddChild(stmt); 
		} else SynErr(166);
	}
 public override object Visit(LocalVariableDeclaration localVariableDeclaration, object data)
 {
     //			Console.WriteLine(localVariableDeclaration);
     outputFormatter.Indent();
     VisitModifier(localVariableDeclaration.Modifier);
     Visit(localVariableDeclaration.Type, data);
     outputFormatter.Space();
     this.AppendCommaSeparatedList(localVariableDeclaration.Variables);
     outputFormatter.PrintToken(Tokens.Semicolon);
     outputFormatter.NewLine();
     return null;
 }