本文整理汇总了C#中VariableDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# VariableDeclaration类的具体用法?C# VariableDeclaration怎么用?C# VariableDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VariableDeclaration类属于命名空间,在下文中一共展示了VariableDeclaration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ForExpression
public ForExpression(Position pos, VariableDeclaration varDec, Expression high, Expression body)
{
Pos = pos;
VarDec = varDec;
High = high;
Body = body;
}
开发者ID:Nxun,项目名称:Naive-Tiger,代码行数:7,代码来源:AbstractSyntax.Expression.cs
示例2: VisitVariableDeclaration
public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
if (nameComparer.Equals(from, variableDeclaration.Name)) {
variableDeclaration.Name = to;
}
return base.VisitVariableDeclaration(variableDeclaration, data);
}
开发者ID:mgagne-atman,项目名称:Projects,代码行数:7,代码来源:RenameIdentifierVisitor.cs
示例3: LocalVariablesDeclaration
public LocalVariablesDeclaration(Expression type, VariableDeclaration variables,
TokenPosition position)
: base(position)
{
this.type = type;
this.variables = variables;
}
开发者ID:ronsaldo,项目名称:chela,代码行数:7,代码来源:LocalVariablesDeclaration.cs
示例4: visit
public void visit(VariableDeclaration node)
{
if (symboltable.resolve(node.Name) != null)
throw new SemanticError("Variable " + node.Name +
" is already defined (row " + node.Row + ").");
Symbol symbol = new Symbol(node.Name, node.Type);
symboltable.define(symbol);
}
开发者ID:Lateks,项目名称:Mini-PL-Interpreter,代码行数:8,代码来源:SemanticAnalysis.cs
示例5: Walk
public override object Walk(VariableDeclaration node)
{
var value = node.Initializer == null
? null
: node.Initializer.Accept(this);
Context.CurrentFrame.Define(node.Identifier.Value, value);
return value;
}
开发者ID:buunguyen,项目名称:bike,代码行数:8,代码来源:Interpreter.cs
示例6: Walk
public virtual object Walk(VariableDeclaration node)
{
if (Enter(node))
{
node.Identifier.Accept(this);
if (node.Initializer != null)
node.Initializer.Accept(this);
}
Exit(node);
return null;
}
开发者ID:buunguyen,项目名称:bike,代码行数:11,代码来源:NodeWalker.cs
示例7: InvalidRange
public void InvalidRange()
{
var stringlit = new StringLiteral("foo", 0);
var range = new Range(stringlit, stringlit, 0);
var variabledecl = new VariableDeclaration("foo", "int", 0);
var variable = new VariableReference("foo", 0);
var loop = new Loop(variable, range, new List<Statement>(), 0);
statementlist.Add(variabledecl);
statementlist.Add(loop);
var parsetree = new Program(statementlist);
Assert.Throws<SemanticError>(() => symbolTableBuilder.BuildSymbolTableAndTypeCheck(parsetree));
}
开发者ID:Lateks,项目名称:Mini-PL-Interpreter,代码行数:13,代码来源:SemanticAnalysisTest.cs
示例8: NonIntegerLoopVariable
public void NonIntegerLoopVariable(string type)
{
var variabledecl = new VariableDeclaration("foo", type, 0);
statementlist.Add(variabledecl);
var variable = new VariableReference("foo", 0);
var integer = new IntegerLiteral("5", 0);
var range = new Range(integer, integer, 0);
var variabledecl2 = new VariableDeclaration("bar", "int", 0);
var loopbody = new List<Statement>();
loopbody.Add(variabledecl2);
var loop = new Loop(variable, range, loopbody, 0);
statementlist.Add(loop);
var parsetree = new Program(statementlist);
Assert.Throws<SemanticError>(() => symbolTableBuilder.BuildSymbolTableAndTypeCheck(parsetree));
}
开发者ID:Lateks,项目名称:Mini-PL-Interpreter,代码行数:16,代码来源:SemanticAnalysisTest.cs
示例9: FalseAnd
public void FalseAnd()
{
var falseboolean = new LogicalOp("=", new IntegerLiteral("4", 0), new IntegerLiteral("5", 0), 0);
var trueboolean = new LogicalOp("=", new IntegerLiteral("4", 0), new IntegerLiteral("5", 0), 0);
var and1 = new LogicalOp("&", falseboolean, trueboolean, 0);
var and2 = new LogicalOp("&", falseboolean, falseboolean, 0);
var assignment1 = new Assignment(result, and1, 0);
program.Add(assignment1);
var result2 = new VariableDeclaration("result2", "bool", 0);
symboltable.define(new Symbol("result2", "bool"));
var assignment2 = new Assignment(result2, and2, 0);
program.Add(assignment2);
interpreter.Run(new Program(program));
Assert.That(interpreter.Valuetable[symboltable.resolve("result")], Is.EqualTo(false));
Assert.That(interpreter.Valuetable[symboltable.resolve("result2")], Is.EqualTo(false));
}
开发者ID:Lateks,项目名称:Mini-PL-Interpreter,代码行数:17,代码来源:InterpretingNodeVisitorTest.cs
示例10: MatchesLocalVariable
private static bool MatchesLocalVariable(SrcMLDataContext db, VariableDeclaration def, XElement use)
{
if (def.IsGlobal ?? false)
return false;
if (def.DeclarationName != use.Value)
return false;
var useXPath = use.GetXPath(false);
var validScopes = from scope in db.ValidScopes
where scope.DefinitionId == def.Id
select scope;
foreach (var scope in validScopes)
{
if (useXPath.StartsWith(scope.XPath))
return true;
}
var method = (from ancestor in use.Ancestors()
where ContainerNames.MethodDefinitions.Any(mn => mn == ancestor.Name)
select ancestor).FirstOrDefault();
var classNameFromMethod = SrcMLHelper.GetClassNameForMethod(method);
if (null == classNameFromMethod)
{
return false;
}
var classDef = from scope in def.ValidScopes.OfType<TypeDefinition>()
where scope.TypeName == classNameFromMethod.Value
select scope;
if (classDef.Any())
{
return true;
}
return false;
}
开发者ID:vinayaugustine,项目名称:SrcML.NET,代码行数:38,代码来源:DeclarationTester.cs
示例11: Exit
public override void Exit(VariableDeclaration node)
{
level--;
}
开发者ID:buunguyen,项目名称:bike,代码行数:4,代码来源:PrintNodeWalker.cs
示例12: Exit
public virtual void Exit(VariableDeclaration node)
{
}
开发者ID:buunguyen,项目名称:bike,代码行数:3,代码来源:EnterForWalkerGenerator.cs
示例13: Enter
public virtual bool Enter(VariableDeclaration node)
{
return true;
}
开发者ID:buunguyen,项目名称:bike,代码行数:4,代码来源:EnterForWalkerGenerator.cs
示例14: Using
public Using (Expression expr, Statement stmt, Location loc)
: base (stmt, loc)
{
this.decl = new VariableDeclaration (expr);
}
开发者ID:alisci01,项目名称:mono,代码行数:5,代码来源:statement.cs
示例15: VisitVariableDeclaration
public virtual Differences VisitVariableDeclaration(VariableDeclaration variableDeclaration1, VariableDeclaration variableDeclaration2){
Differences differences = new Differences(variableDeclaration1, variableDeclaration2);
if (variableDeclaration1 == null || variableDeclaration2 == null){
if (variableDeclaration1 != variableDeclaration2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
return differences;
}
VariableDeclaration changes = (VariableDeclaration)variableDeclaration2.Clone();
VariableDeclaration deletions = (VariableDeclaration)variableDeclaration2.Clone();
VariableDeclaration insertions = (VariableDeclaration)variableDeclaration2.Clone();
// variableDeclaration1.Field;
// variableDeclaration1.Initializer;
// variableDeclaration1.Name;
// variableDeclaration1.Type;
if (differences.NumberOfDifferences == 0){
differences.Changes = null;
differences.Deletions = null;
differences.Insertions = null;
}else{
differences.Changes = changes;
differences.Deletions = deletions;
differences.Insertions = insertions;
}
return differences;
}
开发者ID:tapicer,项目名称:resource-contracts-.net,代码行数:26,代码来源:Comparer.cs
示例16: RewriteForDeclarators
public Statement RewriteForDeclarators (BlockContext bc, Statement stmt)
{
for (int i = declarators.Count - 1; i >= 0; --i) {
var d = declarators [i];
var vd = new VariableDeclaration (d.Variable, type_expr.Location);
vd.Initializer = d.Initializer;
vd.IsNested = true;
vd.dispose_call = CreateDisposeCall (bc, d.Variable);
vd.dispose_call.Resolve (bc);
stmt = new Using (vd, stmt, d.Variable.Location);
}
declarators = null;
return stmt;
}
开发者ID:alisci01,项目名称:mono,代码行数:16,代码来源:statement.cs
示例17: Visit
public override void Visit(VariableDeclaration node)
{
if (node.EnclosingScope is GlobalScope && node.Identifier == varName)
{
found = true;
}
base.Visit(node);
}
开发者ID:joshperry,项目名称:cassette,代码行数:9,代码来源:PlainScript.cs
示例18: Fixed
public Fixed (VariableDeclaration decl, Statement stmt, Location l)
{
this.decl = decl;
statement = stmt;
loc = l;
}
开发者ID:alisci01,项目名称:mono,代码行数:6,代码来源:statement.cs
示例19: RelocateVar
private static int RelocateVar(Block block, int insertAt, Var varStatement)
{
// if the var statement is at the next position to insert, then we don't need
// to do anything.
if (block[insertAt] != varStatement && !InsideConditionalComment(varStatement))
{
// check to see if the current position is a var and we are the NEXT statement.
// if that's the case, we don't need to break out the initializer, just append all the
// vardecls as-is to the current position.
var existingVar = block[insertAt] as Var;
if (existingVar != null && block[insertAt + 1] == varStatement)
{
// just append our vardecls to the insertion point, then delete our statement
existingVar.Append(varStatement);
block.RemoveAt(insertAt + 1);
}
else
{
// iterate through the decls and count how many have initializers
var initializerCount = 0;
for (var ndx = 0; ndx < varStatement.Count; ++ndx)
{
if (varStatement[ndx].Initializer != null)
{
++initializerCount;
}
}
// if there are more than two decls with initializers, then we won't actually
// be gaining anything by moving the var to the top. We'll get rid of the four
// bytes for the "var ", but we'll be adding two bytes for the name and comma
// because name=init will still need to remain behind.
if (initializerCount <= 2)
{
// first iterate through all the declarations in the var statement,
// constructing an expression statement that is made up of assignment
// operators for each of the declarations that have initializers (if any)
// and removing all the initializers
var assignments = new List<AstNode>();
for (var ndx = 0; ndx < varStatement.Count; ++ndx)
{
var varDecl = varStatement[ndx];
if (varDecl.Initializer != null)
{
if (varDecl.IsCCSpecialCase)
{
// create a vardecl with the same name and no initializer
var copyDecl = new VariableDeclaration(
varDecl.Context,
varDecl.Parser,
varDecl.Identifier,
varDecl.Field.OriginalContext,
null,
0,
true);
// replace the special vardecl with the copy
varStatement.ReplaceChild(varDecl, copyDecl);
// add the original vardecl to the list of "assignments"
assignments.Add(varDecl);
}
else
{
// hold on to the object so we don't lose it to the GC
var initializer = varDecl.Initializer;
// remove it from the vardecl
varDecl.ReplaceChild(initializer, null);
// create an assignment operator for a lookup to the name
// as the left, and the initializer as the right, and add it to the list
assignments.Add(new BinaryOperator(
varDecl.Context,
varDecl.Parser,
new Lookup(varDecl.Identifier, varDecl.Field.OriginalContext, varDecl.Parser),
initializer,
JSToken.Assign));
}
}
}
// now if there were any initializers...
if (assignments.Count > 0)
{
// we want to create one big expression from all the assignments and replace the
// var statement with the assignment(s) expression. Start at position n=1 and create
// a binary operator of n-1 as the left, n as the right, and using a comma operator.
var expression = assignments[0];
for (var ndx = 1; ndx < assignments.Count; ++ndx)
{
expression = new BinaryOperator(
null,
expression.Parser,
expression,
assignments[ndx],
JSToken.Comma);
}
// replace the var with the expression.
//.........这里部分代码省略.........
开发者ID:nuxleus,项目名称:ajaxmin,代码行数:101,代码来源:ReorderScopeVisitor.cs
示例20: VisitVariableDeclaration
public virtual Statement VisitVariableDeclaration(VariableDeclaration variableDeclaration){
if (variableDeclaration == null) return null;
variableDeclaration.Type = this.VisitTypeReference(variableDeclaration.Type);
variableDeclaration.Initializer = this.VisitExpression(variableDeclaration.Initializer);
return variableDeclaration;
}
开发者ID:dbremner,项目名称:specsharp,代码行数:6,代码来源:StandardVisitor.cs
注:本文中的VariableDeclaration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论