本文整理汇总了C#中Mono.CSharp.LocalVariable类的典型用法代码示例。如果您正苦于以下问题:C# LocalVariable类的具体用法?C# LocalVariable怎么用?C# LocalVariable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocalVariable类属于Mono.CSharp命名空间,在下文中一共展示了LocalVariable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emitter
protected Emitter (Expression expr, LocalVariable li)
: base (expr)
{
vi = li;
}
示例2: CaptureLocalVariable
public void CaptureLocalVariable (ResolveContext ec, LocalVariable localVariable)
{
if (this is StateMachine) {
if (ec.CurrentBlock.ParametersBlock != localVariable.Block.ParametersBlock)
ec.CurrentBlock.Explicit.HasCapturedVariable = true;
} else {
ec.CurrentBlock.Explicit.HasCapturedVariable = true;
}
var hoisted = localVariable.HoistedVariant;
if (hoisted != null && hoisted.Storey != this && hoisted.Storey is StateMachine) {
//
// Variable is already hoisted but we need it in storey which can be shared
//
hoisted.Storey.hoisted_locals.Remove (hoisted);
hoisted.Storey.Members.Remove (hoisted.Field);
hoisted = null;
}
if (hoisted == null) {
hoisted = new HoistedLocalVariable (this, localVariable, GetVariableMangledName (localVariable));
localVariable.HoistedVariant = hoisted;
if (hoisted_locals == null)
hoisted_locals = new List<HoistedVariable> ();
hoisted_locals.Add (hoisted);
}
if (ec.CurrentBlock.Explicit != localVariable.Block.Explicit && !(hoisted.Storey is StateMachine))
hoisted.Storey.AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit);
}
示例3: GetVariableMangledName
protected virtual string GetVariableMangledName (LocalVariable local_info)
{
//
// No need to mangle anonymous method hoisted variables cause they
// are hoisted in their own scopes
//
return local_info.Name;
}
示例4: case_873
void case_873()
#line 5818 "cs-parser.jay"
{
var lt = (LocatedToken) yyVals[0+yyTop];
var li = new LocalVariable (current_block, lt.Value, lt.Location);
current_block.AddLocalName (li);
current_variable = new BlockVariable ((FullNamedExpression) yyVals[-1+yyTop], li);
}
示例5: case_885
void case_885()
#line 5899 "cs-parser.jay"
{
start_block (GetLocation (yyVals[-5+yyTop]));
current_block.IsCompilerGenerated = true;
var lt = (LocatedToken) yyVals[-3+yyTop];
var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ForeachVariable | LocalVariable.Flags.Used, lt.Location);
current_block.AddLocalName (li);
yyVal = li;
}
示例6: CaptureLocalVariable
public void CaptureLocalVariable (ResolveContext ec, LocalVariable local_info)
{
ec.CurrentBlock.Explicit.HasCapturedVariable = true;
if (ec.CurrentBlock.Explicit != local_info.Block.Explicit)
AddReferenceFromChildrenBlock (ec.CurrentBlock.Explicit);
if (local_info.HoistedVariant != null)
return;
HoistedVariable var = new HoistedLocalVariable (this, local_info, GetVariableMangledName (local_info));
local_info.HoistedVariant = var;
if (hoisted_locals == null)
hoisted_locals = new List<HoistedVariable> ();
hoisted_locals.Add (var);
}
示例7: case_813
void case_813()
#line 5458 "cs-parser.jay"
{
var lt = (LocatedToken) yyVals[0+yyTop];
var li = new LocalVariable (current_variable.Variable, lt.Value, lt.Location);
var d = new BlockVariableDeclarator (li, null);
current_variable.AddDeclarator (d);
current_block.AddLocalName (li);
lbag.AddLocation (d, GetLocation (yyVals[-1+yyTop]));
}
示例8: VariableDeclaration
public VariableDeclaration (LocalVariable li, Location loc)
: base (li)
{
this.loc = loc;
}
示例9: ResolveInitializer
protected override Expression ResolveInitializer (BlockContext bc, LocalVariable li, Expression initializer)
{
Assign assign;
if (li.Type == InternalType.Dynamic) {
initializer = initializer.Resolve (bc);
if (initializer == null)
return null;
initializer = Convert.ImplicitConversionRequired (bc, initializer, TypeManager.idisposable_type, loc);
if (initializer == null)
return null;
var var = LocalVariable.CreateCompilerGenerated (TypeManager.idisposable_type, bc.CurrentBlock, loc);
assign = new SimpleAssign (var.CreateReferenceExpression (bc, loc), initializer, loc);
assign.ResolveStatement (bc);
dispose_call = CreateDisposeCall (bc, var);
dispose_call.Resolve (bc);
return assign;
}
if (li == Variable) {
CheckIDiposableConversion (bc, li, initializer);
dispose_call = CreateDisposeCall (bc, li);
dispose_call.Resolve (bc);
}
return base.ResolveInitializer (bc, li, initializer);
}
示例10: DoResolve
protected override Expression DoResolve (ResolveContext rc)
{
pinned_string = new LocalVariable (vi.Block, "$pinned",
LocalVariable.Flags.FixedVariable | LocalVariable.Flags.CompilerGenerated | LocalVariable.Flags.Used,
vi.Location);
pinned_string.Type = TypeManager.string_type;
if (TypeManager.int_get_offset_to_string_data == null) {
TypeManager.int_get_offset_to_string_data = TypeManager.GetPredefinedProperty (
TypeManager.runtime_helpers_type, "OffsetToStringData", pinned_string.Location, TypeManager.int32_type);
}
eclass = ExprClass.Variable;
type = TypeManager.int32_type;
return this;
}
示例11: StringEmitter
public StringEmitter (Expression expr, LocalVariable li, Location loc)
: base (expr, li)
{
}
示例12: ExpressionEmitter
public ExpressionEmitter (Expression converted, LocalVariable li) :
base (converted, li)
{
}
示例13: CheckIDiposableConversion
protected virtual void CheckIDiposableConversion (BlockContext bc, LocalVariable li, Expression initializer)
{
var type = li.Type;
if (type != TypeManager.idisposable_type && !type.ImplementsInterface (TypeManager.idisposable_type, false)) {
if (TypeManager.IsNullableType (type)) {
// it's handled in CreateDisposeCall
return;
}
bc.Report.SymbolRelatedToPreviousError (type);
var loc = type_expr == null ? initializer.Location : type_expr.Location;
bc.Report.Error (1674, loc, "`{0}': type used in a using statement must be implicitly convertible to `System.IDisposable'",
type.GetSignatureForError ());
return;
}
}
示例14: VariableInfo
public VariableInfo (LocalVariable local_info, int offset)
: this (local_info.Name, local_info.Type, offset)
{
this.IsParameter = false;
}
示例15: CreateDisposeCall
protected virtual Statement CreateDisposeCall (BlockContext bc, LocalVariable lv)
{
var lvr = lv.CreateReferenceExpression (bc, lv.Location);
var type = lv.Type;
var loc = lv.Location;
if (TypeManager.void_dispose_void == null) {
TypeManager.void_dispose_void = TypeManager.GetPredefinedMethod (
TypeManager.idisposable_type, "Dispose", loc, TypeSpec.EmptyTypes);
}
var dispose_mg = MethodGroupExpr.CreatePredefined (TypeManager.void_dispose_void, TypeManager.idisposable_type, loc);
dispose_mg.InstanceExpression = TypeManager.IsNullableType (type) ?
new Cast (new TypeExpression (TypeManager.idisposable_type, loc), lvr, loc).Resolve (bc) :
lvr;
Statement dispose = new StatementExpression (new Invocation (dispose_mg, null));
// Add conditional call when disposing possible null variable
if (!type.IsStruct || TypeManager.IsNullableType (type))
dispose = new If (new Binary (Binary.Operator.Inequality, lvr, new NullLiteral (loc), loc), dispose, loc);
return dispose;
}