本文整理汇总了C#中Mono.CSharp.LocalVariableReference类的典型用法代码示例。如果您正苦于以下问题:C# LocalVariableReference类的具体用法?C# LocalVariableReference怎么用?C# LocalVariableReference使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocalVariableReference类属于Mono.CSharp命名空间,在下文中一共展示了LocalVariableReference类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Visit
public override object Visit (LocalVariableReference localVariableReference)
{
return new Identifier (localVariableReference.Name, Convert (localVariableReference.Location));;
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:4,代码来源:CSharpParser.cs
示例2: DoDefineMembers
protected override bool DoDefineMembers ()
{
if (!base.DoDefineMembers ())
return false;
Location loc = Location;
var equals_parameters = ParametersCompiled.CreateFullyResolved (
new Parameter (new TypeExpression (Compiler.BuiltinTypes.Object, loc), "obj", 0, null, loc), Compiler.BuiltinTypes.Object);
Method equals = new Method (this, new TypeExpression (Compiler.BuiltinTypes.Bool, loc),
Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Equals", loc),
equals_parameters, null);
equals_parameters[0].Resolve (equals, 0);
Method tostring = new Method (this, new TypeExpression (Compiler.BuiltinTypes.String, loc),
Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("ToString", loc),
Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);
ToplevelBlock equals_block = new ToplevelBlock (Compiler, equals.ParameterInfo, loc);
TypeExpr current_type;
if (CurrentTypeParameters != null) {
var targs = new TypeArguments ();
for (int i = 0; i < CurrentTypeParameters.Count; ++i) {
targs.Add (new TypeParameterExpr (CurrentTypeParameters[i], Location));
}
current_type = new GenericTypeExpr (Definition, targs, loc);
} else {
current_type = new TypeExpression (Definition, loc);
}
var li_other = LocalVariable.CreateCompilerGenerated (CurrentType, equals_block, loc);
equals_block.AddStatement (new BlockVariableDeclaration (new TypeExpression (li_other.Type, loc), li_other));
var other_variable = new LocalVariableReference (li_other, loc);
MemberAccess system_collections_generic = new MemberAccess (new MemberAccess (
new QualifiedAliasMember ("global", "System", loc), "Collections", loc), "Generic", loc);
Expression rs_equals = null;
Expression string_concat = new StringConstant (Compiler.BuiltinTypes, "{", loc);
Expression rs_hashcode = new IntConstant (Compiler.BuiltinTypes, -2128831035, loc);
for (int i = 0; i < parameters.Count; ++i) {
var p = parameters [i];
var f = (Field) Members [i * 2];
MemberAccess equality_comparer = new MemberAccess (new MemberAccess (
system_collections_generic, "EqualityComparer",
new TypeArguments (new SimpleName (CurrentTypeParameters [i].Name, loc)), loc),
"Default", loc);
Arguments arguments_equal = new Arguments (2);
arguments_equal.Add (new Argument (new MemberAccess (new This (f.Location), f.Name)));
arguments_equal.Add (new Argument (new MemberAccess (other_variable, f.Name)));
Expression field_equal = new Invocation (new MemberAccess (equality_comparer,
"Equals", loc), arguments_equal);
Arguments arguments_hashcode = new Arguments (1);
arguments_hashcode.Add (new Argument (new MemberAccess (new This (f.Location), f.Name)));
Expression field_hashcode = new Invocation (new MemberAccess (equality_comparer,
"GetHashCode", loc), arguments_hashcode);
IntConstant FNV_prime = new IntConstant (Compiler.BuiltinTypes, 16777619, loc);
rs_hashcode = new Binary (Binary.Operator.Multiply,
new Binary (Binary.Operator.ExclusiveOr, rs_hashcode, field_hashcode),
FNV_prime);
Expression field_to_string = new Conditional (new BooleanExpression (new Binary (Binary.Operator.Inequality,
new MemberAccess (new This (f.Location), f.Name), new NullLiteral (loc))),
new Invocation (new MemberAccess (
new MemberAccess (new This (f.Location), f.Name), "ToString"), null),
new StringConstant (Compiler.BuiltinTypes, string.Empty, loc), loc);
if (rs_equals == null) {
rs_equals = field_equal;
string_concat = new Binary (Binary.Operator.Addition,
string_concat,
new Binary (Binary.Operator.Addition,
new StringConstant (Compiler.BuiltinTypes, " " + p.Name + " = ", loc),
field_to_string));
continue;
}
//
// Implementation of ToString () body using string concatenation
//
string_concat = new Binary (Binary.Operator.Addition,
new Binary (Binary.Operator.Addition,
string_concat,
new StringConstant (Compiler.BuiltinTypes, ", " + p.Name + " = ", loc)),
field_to_string);
rs_equals = new Binary (Binary.Operator.LogicalAnd, rs_equals, field_equal);
}
string_concat = new Binary (Binary.Operator.Addition,
string_concat,
//.........这里部分代码省略.........
开发者ID:rabink,项目名称:mono,代码行数:101,代码来源:anonymous.cs
示例3: Body
public Body (TypeSpec type, LocalVariable variable,
Expression current, Statement statement,
Location loc)
{
this.type = type;
this.variable = new LocalVariableReference (variable, loc);
this.current = current;
this.statement = statement;
this.loc = loc;
}
开发者ID:alisci01,项目名称:mono,代码行数:10,代码来源:statement.cs
示例4: Visit
public virtual object Visit (LocalVariableReference localVariableReference)
{
return null;
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:visit.cs
示例5: Foreach
public Foreach (Expression type, LocalVariableReference var, Expression expr,
Statement stmt, Location l)
{
this.type = type;
this.variable = var;
this.expr = expr;
statement = stmt;
loc = l;
}
开发者ID:tgiphil,项目名称:mono,代码行数:9,代码来源:statement.cs
示例6: ArrayForeach
public ArrayForeach (Foreach @foreach, int rank)
{
for_each = @foreach;
statement = for_each.statement;
loc = @foreach.loc;
variable = new LocalVariableReference (for_each.variable, loc);
counter = new StatementExpression[rank];
variables = new TemporaryVariableReference[rank];
length_exprs = new Expression [rank];
//
// Only use temporary length variables when dealing with
// multi-dimensional arrays
//
if (rank > 1)
lengths = new TemporaryVariableReference [rank];
}
开发者ID:alisci01,项目名称:mono,代码行数:18,代码来源:statement.cs
示例7: yyparse
//.........这里部分代码省略.........
yyVal = new While ((BooleanExpression) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], l);
}
break;
case 766:
#line 4911 "cs-parser.jay"
{
Location l = GetLocation (yyVals[-6+yyTop]);
yyVal = new Do ((Statement) yyVals[-5+yyTop], (BooleanExpression) yyVals[-2+yyTop], l);
}
break;
case 767:
#line 4920 "cs-parser.jay"
{
Location l = lexer.Location;
start_block (l);
Block assign_block = current_block;
if (yyVals[-1+yyTop] is Tuple<FullNamedExpression, List<object>>){
var de = (Tuple<FullNamedExpression, List<object>>) yyVals[-1+yyTop];
var type = de.Item1;
foreach (VariableDeclaration decl in de.Item2){
LocalInfo vi;
vi = current_block.AddVariable (type, decl.identifier, decl.Location);
if (vi == null)
continue;
Expression expr = decl.GetInitializer (type);
LocalVariableReference var;
var = new LocalVariableReference (assign_block, decl.identifier, l);
if (expr != null) {
Assign a = new SimpleAssign (var, expr, decl.Location);
assign_block.AddStatement (new StatementExpression (a));
}
}
/* Note: the $$ below refers to the value of this code block, not of the LHS non-terminal.*/
/* This can be referred to as $5 below.*/
yyVal = null;
} else {
yyVal = yyVals[-1+yyTop];
}
}
break;
case 768:
#line 4960 "cs-parser.jay"
{
Location l = GetLocation (yyVals[-9+yyTop]);
For f = new For ((Statement) yyVals[-5+yyTop], (BooleanExpression) yyVals[-4+yyTop], (Statement) yyVals[-2+yyTop], (Statement) yyVals[0+yyTop], l);
current_block.AddStatement (f);
yyVal = end_block (lexer.Location);
}
break;
case 769:
#line 4972 "cs-parser.jay"
{ yyVal = new EmptyStatement (lexer.Location); }
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs
示例8: DoEmit
protected override void DoEmit (EmitContext ec)
{
if (CatchType != null)
ec.BeginCatchBlock (CatchType);
else
ec.BeginCatchBlock (TypeManager.object_type);
if (VarBlock != null)
VarBlock.Emit (ec);
if (Name != null) {
// TODO: Move to resolve
LocalVariableReference lvr = new LocalVariableReference (Block, Name, loc);
lvr.Resolve (new ResolveContext (ec.MemberContext));
// Only to make verifier happy
if (TypeManager.IsGenericParameter (lvr.Type))
ec.Emit (OpCodes.Unbox_Any, lvr.Type);
Expression source;
if (lvr.IsHoisted) {
LocalTemporary lt = new LocalTemporary (lvr.Type);
lt.Store (ec);
source = lt;
} else {
// Variable is at the top of the stack
source = EmptyExpression.Null;
}
lvr.EmitAssign (ec, source, false, false);
} else
ec.Emit (OpCodes.Pop);
Block.Emit (ec);
}
开发者ID:tgiphil,项目名称:mono,代码行数:35,代码来源:statement.cs
示例9: DoSimpleNameResolve
/// <remarks>
/// 7.5.2: Simple Names.
///
/// Local Variables and Parameters are handled at
/// parse time, so they never occur as SimpleNames.
///
/// The `intermediate' flag is used by MemberAccess only
/// and it is used to inform us that it is ok for us to
/// avoid the static check, because MemberAccess might end
/// up resolving the Name as a Type name and the access as
/// a static type access.
///
/// ie: Type Type; .... { Type.GetType (""); }
///
/// Type is both an instance variable and a Type; Type.GetType
/// is the static method not an instance method of type.
/// </remarks>
Expression DoSimpleNameResolve(ResolveContext ec, Expression right_side, bool intermediate)
{
Expression e = null;
//
// Stage 1: Performed by the parser (binding to locals or parameters).
//
Block current_block = ec.CurrentBlock;
if (current_block != null){
LocalInfo vi = current_block.GetLocalInfo (Name);
if (vi != null){
e = new LocalVariableReference (ec.CurrentBlock, Name, loc);
if (right_side != null) {
e = e.ResolveLValue (ec, right_side);
} else {
if (intermediate) {
using (ec.With (ResolveContext.Options.DoFlowAnalysis, false)) {
e = e.Resolve (ec, ResolveFlags.VariableOrValue);
}
} else {
e = e.Resolve (ec, ResolveFlags.VariableOrValue);
}
}
if (HasTypeArguments && e != null)
e.Error_TypeArgumentsCannotBeUsed (ec.Report, loc, null, 0);
return e;
}
e = current_block.Toplevel.GetParameterReference (Name, loc);
if (e != null) {
if (right_side != null)
e = e.ResolveLValue (ec, right_side);
else
e = e.Resolve (ec);
if (HasTypeArguments && e != null)
e.Error_TypeArgumentsCannotBeUsed (ec.Report, loc, null, 0);
return e;
}
}
//
// Stage 2: Lookup members
//
int arity = HasTypeArguments ? Arity : -1;
// TypeSpec almost_matched_type = null;
// IList<MemberSpec> almost_matched = null;
for (TypeSpec lookup_ds = ec.CurrentType; lookup_ds != null; lookup_ds = lookup_ds.DeclaringType) {
e = MemberLookup (ec.Compiler, ec.CurrentType, lookup_ds, Name, arity, BindingRestriction.NoOverrides, loc);
if (e != null) {
PropertyExpr pe = e as PropertyExpr;
if (pe != null) {
// since TypeManager.MemberLookup doesn't know if we're doing a lvalue access or not,
// it doesn't know which accessor to check permissions against
if (pe.PropertyInfo.Kind == MemberKind.Property && pe.IsAccessibleFrom (ec.CurrentType, right_side != null))
break;
} else if (e is EventExpr) {
if (((EventExpr) e).IsAccessibleFrom (ec.CurrentType))
break;
} else if (HasTypeArguments && e is TypeExpression) {
e = new GenericTypeExpr (e.Type, targs, loc).ResolveAsTypeStep (ec, false);
break;
} else {
break;
}
e = null;
}
/*
if (almost_matched == null && almost_matched_members.Count > 0) {
almost_matched_type = lookup_ds;
almost_matched = new List<MemberSpec>(almost_matched_members);
}
*/
}
if (e == null) {
/*
if (almost_matched == null && almost_matched_members.Count > 0) {
almost_matched_type = ec.CurrentType;
//.........这里部分代码省略.........
开发者ID:speier,项目名称:shake,代码行数:101,代码来源:ecore.cs
示例10: CreateExpressionTreeVariable
public ExpressionStatement CreateExpressionTreeVariable (EmitContext ec)
{
if ((modFlags & Modifier.ISBYREF) != 0)
Report.Error (1951, Location, "An expression tree parameter cannot use `ref' or `out' modifier");
LocalInfo variable = ec.CurrentBlock.AddTemporaryVariable (
ResolveParameterExpressionType (ec, Location), Location);
variable.Resolve (ec);
expr_tree_variable = new LocalVariableReference (
ec.CurrentBlock, variable.Name, Location, variable, false);
ArrayList arguments = new ArrayList (2);
arguments.Add (new Argument (new TypeOf (
new TypeExpression (parameter_type, Location), Location)));
arguments.Add (new Argument (new StringConstant (Name, Location)));
return new SimpleAssign (ExpressionTreeVariableReference (),
Expression.CreateExpressionFactoryCall ("Parameter", null, arguments, Location));
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:19,代码来源:parameter.cs
示例11: DoSimpleNameResolve
/// <remarks>
/// 7.5.2: Simple Names.
///
/// Local Variables and Parameters are handled at
/// parse time, so they never occur as SimpleNames.
///
/// The `intermediate' flag is used by MemberAccess only
/// and it is used to inform us that it is ok for us to
/// avoid the static check, because MemberAccess might end
/// up resolving the Name as a Type name and the access as
/// a static type access.
///
/// ie: Type Type; .... { Type.GetType (""); }
///
/// Type is both an instance variable and a Type; Type.GetType
/// is the static method not an instance method of type.
/// </remarks>
Expression DoSimpleNameResolve (EmitContext ec, Expression right_side, bool intermediate)
{
Expression e = null;
//
// Stage 1: Performed by the parser (binding to locals or parameters).
//
Block current_block = ec.CurrentBlock;
if (current_block != null){
LocalInfo vi = current_block.GetLocalInfo (Name);
if (vi != null){
LocalVariableReference var = new LocalVariableReference (ec.CurrentBlock, Name, loc);
if (right_side != null) {
return var.ResolveLValue (ec, right_side, loc);
} else {
ResolveFlags rf = ResolveFlags.VariableOrValue;
if (intermediate)
rf |= ResolveFlags.DisableFlowAnalysis;
return var.Resolve (ec, rf);
}
}
Expression expr = current_block.Toplevel.GetParameterReference (Name, loc);
if (expr != null) {
if (right_side != null)
return expr.ResolveLValue (ec, right_side, loc);
return expr.Resolve (ec);
}
}
//
// Stage 2: Lookup members
//
Type almost_matched_type = null;
ArrayList almost_matched = null;
for (DeclSpace lookup_ds = ec.DeclContainer; lookup_ds != null; lookup_ds = lookup_ds.Parent) {
// either RootDeclSpace or GenericMethod
if (lookup_ds.TypeBuilder == null)
continue;
e = MemberLookup (ec.ContainerType, lookup_ds.TypeBuilder, Name, loc);
if (e != null) {
PropertyExpr pe = e as PropertyExpr;
if (pe != null) {
AParametersCollection param = TypeManager.GetParameterData (pe.PropertyInfo);
// since TypeManager.MemberLookup doesn't know if we're doing a lvalue access or not,
// it doesn't know which accessor to check permissions against
if (param.IsEmpty && pe.IsAccessibleFrom (ec.ContainerType, right_side != null))
break;
} else if (e is EventExpr) {
if (((EventExpr) e).IsAccessibleFrom (ec.ContainerType))
break;
} else if (targs != null && e is TypeExpression) {
e = new GenericTypeExpr (e.Type, targs, loc).ResolveAsTypeStep (ec, false);
break;
} else {
break;
}
e = null;
}
if (almost_matched == null && almost_matched_members.Count > 0) {
almost_matched_type = lookup_ds.TypeBuilder;
almost_matched = (ArrayList) almost_matched_members.Clone ();
}
}
if (e == null) {
if (almost_matched == null && almost_matched_members.Count > 0) {
almost_matched_type = ec.ContainerType;
almost_matched = (ArrayList) almost_matched_members.Clone ();
}
e = ResolveAsTypeStep (ec, true);
}
if (e == null) {
if (current_block != null) {
IKnownVariable ikv = current_block.Explicit.GetKnownVariable (Name);
if (ikv != null) {
LocalInfo li = ikv as LocalInfo;
//.........这里部分代码省略.........
开发者ID:lewurm,项目名称:benchmarker,代码行数:101,代码来源:ecore.cs
示例12: DefineOverrides
void DefineOverrides ()
{
Location loc = Location;
Method equals = new Method (this, null, TypeManager.system_boolean_expr,
Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("Equals", loc),
Mono.CSharp.ParametersCompiled.CreateFullyResolved (new Parameter (null, "obj", 0, null, loc), TypeManager.object_type), null);
Method tostring = new Method (this, null, TypeManager.system_string_expr,
Modifiers.PUBLIC | Modifiers.OVERRIDE | Modifiers.DEBUGGER_HIDDEN, new MemberName ("ToString", loc),
Mono.CSharp.ParametersCompiled.EmptyReadOnlyParameters, null);
ToplevelBlock equals_block = new ToplevelBlock (Compiler, equals.Parameters, loc);
TypeExpr current_type;
if (IsGeneric)
current_type = new GenericTypeExpr (this, loc);
else
current_type = new TypeExpression (TypeBuilder, loc);
equals_block.AddVariable (current_type, "other", loc);
LocalVariableReference other_variable = new LocalVariableReference (equals_block, "other", loc);
MemberAccess system_collections_generic = new MemberAccess (new MemberAccess (
new QualifiedAliasMember ("global", "System", loc), "Collections", loc), "Generic", loc);
Expression rs_equals = null;
Expression string_concat = new StringConstant ("{", loc);
Expression rs_hashcode = new IntConstant (-2128831035, loc);
for (int i = 0; i < parameters.Count; ++i) {
AnonymousTypeParameter p = (AnonymousTypeParameter) parameters [i];
Field f = (Field) Fields [i];
MemberAccess equality_comparer = new MemberAccess (new MemberAccess (
system_collections_generic, "EqualityComparer",
new TypeArguments (new SimpleName (TypeParameters [i].Name, loc)), loc),
"Default", loc);
Arguments arguments_equal = new Arguments (2);
arguments_equal.Add (new Argument (new MemberAccess (new This (f.Location), f.Name)));
arguments_equal.Add (new Argument (new MemberAccess (other_variable, f.Name)));
Expression field_equal = new Invocation (new MemberAccess (equality_comparer,
"Equals", loc), arguments_equal);
Arguments arguments_hashcode = new Arguments (1);
arguments_hashcode.Add (new Argument (new MemberAccess (new This (f.Location), f.Name)));
Expression field_hashcode = new Invocation (new MemberAccess (equality_comparer,
"GetHashCode", loc), arguments_hashcode);
IntConstant FNV_prime = new IntConstant (16777619, loc);
rs_hashcode = new Binary (Binary.Operator.Multiply,
new Binary (Binary.Operator.ExclusiveOr, rs_hashcode, field_hashcode),
FNV_prime);
Expression field_to_string = new Conditional (new Binary (Binary.Operator.Inequality,
new MemberAccess (new This (f.Location), f.Name), new NullLiteral (loc)),
new Invocation (new MemberAccess (
new MemberAccess (new This (f.Location), f.Name), "ToString"), null),
new StringConstant (string.Empty, loc));
if (rs_equals == null) {
rs_equals = field_equal;
string_concat = new Binary (Binary.Operator.Addition,
string_concat,
new Binary (Binary.Operator.Addition,
new StringConstant (" " + p.Name + " = ", loc),
field_to_string));
continue;
}
//
// Implementation of ToString () body using string concatenation
//
string_concat = new Binary (Binary.Operator.Addition,
new Binary (Binary.Operator.Addition,
string_concat,
new StringConstant (", " + p.Name + " = ", loc)),
field_to_string);
rs_equals = new Binary (Binary.Operator.LogicalAnd, rs_equals, field_equal);
}
string_concat = new Binary (Binary.Operator.Addition,
string_concat,
new StringConstant (" }", loc));
//
// Equals (object obj) override
//
LocalVariableReference other_variable_assign = new LocalVariableReference (equals_block, "other", loc);
equals_block.AddStatement (new StatementExpression (
new SimpleAssign (other_variable_assign,
new As (equals_block.GetParameterReference ("obj", loc),
current_type, loc), loc)));
Expression equals_test = new Binary (Binary.Operator.Inequality, other_variable, new NullLiteral (loc));
if (rs_equals != null)
equals_test = new Binary (Binary.Operator.LogicalAnd, equals_test, rs_equals);
equals_block.AddStatement (new Return (equals_test, loc));
//.........这里部分代码省略.........
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:101,代码来源:anonymous.cs
示例13: DoEmit
protected override void DoEmit (EmitContext ec)
{
ILGenerator ig = ec.ig;
if (CatchType != null)
ig.BeginCatchBlock (CatchType);
else
ig.BeginCatchBlock (TypeManager.object_type);
if (VarBlock != null)
VarBlock.Emit (ec);
if (Name != null) {
// TODO: Move to resolve
LocalVariableReference lvr = new LocalVariableReference (Block, Name, loc);
lvr.Resolve (ec);
Expression source;
if (lvr.IsHoisted) {
LocalTemporary lt = new LocalTemporary (lvr.Type);
lt.Store (ec);
source = lt;
} else {
// Variable is at the top of the stack
source = EmptyExpression.Null;
}
lvr.EmitAssign (ec, source, false, false);
} else
ig.Emit (OpCodes.Pop);
Block.Emit (ec);
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:33,代码来源:statement.cs
注:本文中的Mono.CSharp.LocalVariableReference类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论