本文整理汇总了C#中VariableDeclaration类的典型用法代码示例。如果您正苦于以下问题:C# VariableDeclaration类的具体用法?C# VariableDeclaration怎么用?C# VariableDeclaration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VariableDeclaration类属于命名空间,在下文中一共展示了VariableDeclaration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ForExpression
public ForExpression(Position pos, VariableDeclaration varDec, Expression high, Expression body)
{
Pos = pos;
VarDec = varDec;
High = high;
Body = body;
}
示例2: VisitVariableDeclaration
public override object VisitVariableDeclaration(VariableDeclaration variableDeclaration, object data)
{
if (nameComparer.Equals(from, variableDeclaration.Name)) {
variableDeclaration.Name = to;
}
return base.VisitVariableDeclaration(variableDeclaration, data);
}
示例3: LocalVariablesDeclaration
public LocalVariablesDeclaration(Expression type, VariableDeclaration variables,
TokenPosition position)
: base(position)
{
this.type = type;
this.variables = variables;
}
示例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);
}
示例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;
}
示例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;
}
示例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));
}
示例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));
}
示例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));
}
示例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;
}
示例11: Exit
public override void Exit(VariableDeclaration node)
{
level--;
}
示例12: Exit
public virtual void Exit(VariableDeclaration node)
{
}
示例13: Enter
public virtual bool Enter(VariableDeclaration node)
{
return true;
}
示例14: Using
public Using (Expression expr, Statement stmt, Location loc)
: base (stmt, loc)
{
this.decl = new VariableDeclaration (expr);
}
示例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;
}