本文整理汇总了C#中Mono.CSharp.VariableInfo类的典型用法代码示例。如果您正苦于以下问题:C# VariableInfo类的具体用法?C# VariableInfo怎么用?C# VariableInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VariableInfo类属于Mono.CSharp命名空间,在下文中一共展示了VariableInfo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SetAssigned
public void SetAssigned (VariableInfo vi)
{
CurrentUsageVector.SetAssigned (vi);
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:4,代码来源:flowanalysis.cs
示例2: IsFieldAssigned
public bool IsFieldAssigned (VariableInfo var, string name)
{
if (/*!var.IsParameter &&*/ IsUnreachable)
return true;
return var.IsStructFieldAssigned (locals, name);
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:7,代码来源:flowanalysis.cs
示例3: IsAssigned
public bool IsAssigned (VariableInfo vi)
{
return CurrentUsageVector.IsAssigned (vi, false);
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:4,代码来源:flowanalysis.cs
示例4: VariableInfo
protected VariableInfo (VariableInfo parent, TypeInfo type)
{
this.Name = parent.Name;
this.TypeInfo = type;
this.Offset = parent.Offset + type.Offset;
this.Parent = parent;
this.Length = type.TotalLength;
this.IsParameter = parent.IsParameter;
Initialize ();
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:12,代码来源:flowanalysis.cs
示例5: DoResolve
Expression DoResolve(ResolveContext ec, bool lvalue_instance, bool out_access)
{
if (!IsStatic){
if (InstanceExpression == null){
//
// This can happen when referencing an instance field using
// a fully qualified type expression: TypeName.InstanceField = xxx
//
SimpleName.Error_ObjectRefRequired (ec, loc, GetSignatureForError ());
return null;
}
// Resolve the field's instance expression while flow analysis is turned
// off: when accessing a field "a.b", we must check whether the field
// "a.b" is initialized, not whether the whole struct "a" is initialized.
if (lvalue_instance) {
using (ec.With (ResolveContext.Options.DoFlowAnalysis, false)) {
Expression right_side =
out_access ? EmptyExpression.LValueMemberOutAccess : EmptyExpression.LValueMemberAccess;
if (InstanceExpression != EmptyExpression.Null)
InstanceExpression = InstanceExpression.ResolveLValue (ec, right_side);
}
} else {
if (InstanceExpression != EmptyExpression.Null) {
using (ec.With (ResolveContext.Options.DoFlowAnalysis, false)) {
InstanceExpression = InstanceExpression.Resolve (ec, ResolveFlags.VariableOrValue);
}
}
}
if (InstanceExpression == null)
return null;
using (ec.Set (ResolveContext.Options.OmitStructFlowAnalysis)) {
InstanceExpression.CheckMarshalByRefAccess (ec);
}
}
if (!ec.IsObsolete) {
ObsoleteAttribute oa = spec.GetAttributeObsolete ();
if (oa != null)
AttributeTester.Report_ObsoleteMessage (oa, TypeManager.GetFullNameSignature (spec), loc, ec.Report);
}
var fb = spec as FixedFieldSpec;
IVariableReference var = InstanceExpression as IVariableReference;
if (fb != null) {
IFixedExpression fe = InstanceExpression as IFixedExpression;
if (!ec.HasSet (ResolveContext.Options.FixedInitializerScope) && (fe == null || !fe.IsFixed)) {
ec.Report.Error (1666, loc, "You cannot use fixed size buffers contained in unfixed expressions. Try using the fixed statement");
}
if (InstanceExpression.eclass != ExprClass.Variable) {
ec.Report.SymbolRelatedToPreviousError (spec);
ec.Report.Error (1708, loc, "`{0}': Fixed size buffers can only be accessed through locals or fields",
TypeManager.GetFullNameSignature (spec));
} else if (var != null && var.IsHoisted) {
AnonymousMethodExpression.Error_AddressOfCapturedVar (ec, var, loc);
}
return new FixedBufferPtr (this, fb.ElementType, loc).Resolve (ec);
}
eclass = ExprClass.Variable;
// If the instance expression is a local variable or parameter.
if (var == null || var.VariableInfo == null)
return this;
VariableInfo vi = var.VariableInfo;
if (!vi.IsFieldAssigned (ec, Name, loc))
return null;
variable_info = vi.GetSubStruct (Name);
return this;
}
开发者ID:speier,项目名称:shake,代码行数:79,代码来源:ecore.cs
示例6: ResolveMeta
void ResolveMeta (BlockContext ec)
{
int orig_count = parameters.Count;
for (int i = 0; i < orig_count; ++i) {
Parameter.Modifier mod = parameters.FixedParameters[i].ModFlags;
if ((mod & Parameter.Modifier.OUT) != Parameter.Modifier.OUT)
continue;
VariableInfo vi = new VariableInfo (parameters, i, ec.FlowOffset);
parameter_info[i].VariableInfo = vi;
ec.FlowOffset += vi.Length;
}
}
开发者ID:alisci01,项目名称:mono,代码行数:15,代码来源:statement.cs
示例7: ResolveBase
public bool ResolveBase (ResolveContext ec)
{
if (eclass != ExprClass.Invalid)
return true;
eclass = ExprClass.Variable;
type = ec.CurrentType;
if (!IsThisAvailable (ec)) {
if (ec.IsStatic && !ec.HasSet (ResolveContext.Options.ConstantScope)) {
ec.Report.Error (26, loc, "Keyword `this' is not valid in a static property, static method, or static field initializer");
} else if (ec.CurrentAnonymousMethod != null) {
ec.Report.Error (1673, loc,
"Anonymous methods inside structs cannot access instance members of `this'. " +
"Consider copying `this' to a local variable outside the anonymous method and using the local instead");
} else {
ec.Report.Error (27, loc, "Keyword `this' is not available in the current context");
}
}
is_struct = type.IsValueType;
if (block != null) {
if (block.Toplevel.ThisVariable != null)
variable_info = block.Toplevel.ThisVariable.VariableInfo;
AnonymousExpression am = ec.CurrentAnonymousMethod;
if (am != null && ec.IsVariableCapturingRequired) {
am.SetHasThisAccess ();
}
}
return true;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:34,代码来源:expression.cs
示例8: DoResolve
Expression DoResolve (EmitContext ec, bool lvalue_instance, bool out_access)
{
if (!FieldInfo.IsStatic){
if (InstanceExpression == null){
//
// This can happen when referencing an instance field using
// a fully qualified type expression: TypeName.InstanceField = xxx
//
SimpleName.Error_ObjectRefRequired (ec, loc, GetSignatureForError ());
return null;
}
// Resolve the field's instance expression while flow analysis is turned
// off: when accessing a field "a.b", we must check whether the field
// "a.b" is initialized, not whether the whole struct "a" is initialized.
if (lvalue_instance) {
using (ec.With (EmitContext.Flags.DoFlowAnalysis, false)) {
Expression right_side =
out_access ? EmptyExpression.LValueMemberOutAccess : EmptyExpression.LValueMemberAccess;
InstanceExpression = InstanceExpression.ResolveLValue (ec, right_side, loc);
}
} else {
ResolveFlags rf = ResolveFlags.VariableOrValue | ResolveFlags.DisableFlowAnalysis;
InstanceExpression = InstanceExpression.Resolve (ec, rf);
}
if (InstanceExpression == null)
return null;
using (ec.Set (EmitContext.Flags.OmitStructFlowAnalysis)) {
InstanceExpression.CheckMarshalByRefAccess (ec);
}
}
// TODO: the code above uses some non-standard multi-resolve rules
if (eclass != ExprClass.Invalid)
return this;
if (!ec.IsInObsoleteScope) {
FieldBase f = TypeManager.GetField (FieldInfo);
if (f != null) {
f.CheckObsoleteness (loc);
} else {
ObsoleteAttribute oa = AttributeTester.GetMemberObsoleteAttribute (FieldInfo);
if (oa != null)
AttributeTester.Report_ObsoleteMessage (oa, TypeManager.GetFullNameSignature (FieldInfo), loc);
}
}
IFixedBuffer fb = AttributeTester.GetFixedBuffer (FieldInfo);
IVariableReference var = InstanceExpression as IVariableReference;
if (fb != null) {
IFixedExpression fe = InstanceExpression as IFixedExpression;
if (!ec.InFixedInitializer && (fe == null || !fe.IsFixed)) {
Report.Error (1666, loc, "You cannot use fixed size buffers contained in unfixed expressions. Try using the fixed statement");
}
if (InstanceExpression.eclass != ExprClass.Variable) {
Report.SymbolRelatedToPreviousError (FieldInfo);
Report.Error (1708, loc, "`{0}': Fixed size buffers can only be accessed through locals or fields",
TypeManager.GetFullNameSignature (FieldInfo));
} else if (var != null && var.IsHoisted) {
AnonymousMethodExpression.Error_AddressOfCapturedVar (var, loc);
}
return new FixedBufferPtr (this, fb.ElementType, loc).Resolve (ec);
}
eclass = ExprClass.Variable;
// If the instance expression is a local variable or parameter.
if (var == null || var.VariableInfo == null)
return this;
VariableInfo vi = var.VariableInfo;
if (!vi.IsFieldAssigned (ec, FieldInfo.Name, loc))
return null;
variable_info = vi.GetSubStruct (FieldInfo.Name);
eclass = ExprClass.Variable;
return this;
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:84,代码来源:ecore.cs
示例9: ResolveBase
public bool ResolveBase (EmitContext ec)
{
if (eclass != ExprClass.Invalid)
return true;
eclass = ExprClass.Variable;
if (ec.TypeContainer.CurrentType != null)
type = ec.TypeContainer.CurrentType;
else
type = ec.ContainerType;
if (!IsThisAvailable (ec)) {
if (ec.IsStatic) {
Error (26, "Keyword `this' is not valid in a static property, static method, or static field initializer");
} else {
Report.Error (1673, loc,
"Anonymous methods inside structs cannot access instance members of `this'. " +
"Consider copying `this' to a local variable outside the anonymous method and using the local instead");
}
}
is_struct = ec.TypeContainer is Struct;
if (block != null) {
if (block.Toplevel.ThisVariable != null)
variable_info = block.Toplevel.ThisVariable.VariableInfo;
AnonymousExpression am = ec.CurrentAnonymousMethod;
if (am != null) {
//
// this is hoisted to very top level block
//
if (ec.IsVariableCapturingRequired) {
//
// TODO: it should be optimized, see test-anon-75.cs
//
// `this' variable has its own scope which is mostly empty
// and causes creation of extraneous storey references.
// Also it's hard to remove `this' dependencies when we Undo
// this access.
//
AnonymousMethodStorey scope = TopToplevelBlock.Explicit.CreateAnonymousMethodStorey (ec);
if (HoistedVariable == null) {
TopToplevelBlock.HoistedThisVariable = scope.CaptureThis (ec, this);
}
}
}
}
return true;
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:52,代码来源:expression.cs
示例10: IsFullyInitialized
// <summary>
// A struct's constructor must always assign all fields.
// This method checks whether it actually does so.
// </summary>
public bool IsFullyInitialized (FlowBranching branching, VariableInfo vi, Location loc)
{
if (struct_info == null)
return true;
bool ok = true;
for (int i = 0; i < struct_info.Count; i++) {
FieldInfo field = struct_info.Fields [i];
if (!branching.IsFieldAssigned (vi, field.Name)) {
FieldBase fb = TypeManager.GetField (field);
if (fb != null && (fb.ModFlags & Modifiers.BACKING_FIELD) != 0) {
Report.Error (843, loc,
"An automatically implemented property `{0}' must be fully assigned before control leaves the constructor. Consider calling default contructor",
fb.GetSignatureForError ());
} else {
Report.Error (171, loc,
"Field `{0}' must be fully assigned before control leaves the constructor",
TypeManager.GetFullNameSignature (field));
}
ok = false;
}
}
return ok;
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:30,代码来源:flowanalysis.cs
示例11: ResolveMeta
public bool ResolveMeta (EmitContext ec, Parameters ip)
{
int errors = Report.Errors;
int orig_count = parameters.Count;
if (top_level_branching != null)
return true;
if (ip != null)
parameters = ip;
// Assert: orig_count != parameter.Count => orig_count == 0
if (orig_count != 0 && orig_count != parameters.Count)
throw new InternalErrorException ("parameter information mismatch");
int offset = Parent == null ? 0 : Parent.AssignableSlots;
for (int i = 0; i < orig_count; ++i) {
Parameter.Modifier mod = parameters.FixedParameters [i].ModFlags;
if ((mod & Parameter.Modifier.OUT) != Parameter.Modifier.OUT)
continue;
VariableInfo vi = new VariableInfo (ip, i, offset);
parameter_info [i].VariableInfo = vi;
offset += vi.Length;
}
ResolveMeta (ec, offset);
top_level_branching = ec.StartFlowBranching (this);
return Report.Errors == errors;
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:34,代码来源:statement.cs
示例12: SetStructFieldAssigned
public void SetStructFieldAssigned (VariableInfo variable, string name)
{
variable.SetStructFieldAssigned (DefiniteAssignment, name);
}
开发者ID:GirlD,项目名称:mono,代码行数:4,代码来源:context.cs
示例13: IsFullyInitialized
// <summary>
// A struct's constructor must always assign all fields.
// This method checks whether it actually does so.
// </summary>
public bool IsFullyInitialized (FlowAnalysisContext fc, VariableInfo vi, Location loc)
{
if (struct_info == null)
return true;
bool ok = true;
for (int i = 0; i < struct_info.Count; i++) {
var field = struct_info.Fields[i];
if (!fc.IsStructFieldDefinitelyAssigned (vi, field.Name)) {
var bf = field.MemberDefinition as Property.BackingFieldDeclaration;
if (bf != null) {
if (bf.Initializer != null)
continue;
fc.Report.Error (843, loc,
"An automatically implemented property `{0}' must be fully assigned before control leaves the constructor. Consider calling the default struct contructor from a constructor initializer",
field.GetSignatureForError ());
ok = false;
continue;
}
fc.Report.Error (171, loc,
"Field `{0}' must be fully assigned before control leaves the constructor",
field.GetSignatureForError ());
ok = false;
}
}
return ok;
}
开发者ID:psni,项目名称:mono,代码行数:36,代码来源:flowanalysis.cs
示例14: PrepareForFlowAnalysis
public void PrepareForFlowAnalysis (BlockContext bc)
{
//
// No need for definitely assigned check for these guys
//
if ((flags & (Flags.Constant | Flags.ReadonlyMask | Flags.CompilerGenerated)) != 0)
return;
VariableInfo = new VariableInfo (this, bc.FlowOffset);
bc.FlowOffset += VariableInfo.Length;
}
开发者ID:alisci01,项目名称:mono,代码行数:11,代码来源:statement.cs
示例15: Create
public static VariableInfo Create (BlockContext bc, LocalVariable variable)
{
var info = new VariableInfo (variable.Name, variable.Type, bc.AssignmentInfoOffset, bc);
bc.AssignmentInfoOffset += info.Length;
return info;
}
开发者ID:psni,项目名称:mono,代码行数:6,代码来源:flowanalysis.cs
示例16: IsFullyInitialized
// <summary>
// A struct's constructor must always assign all fields.
// This method checks whether it actually does so.
// </summary>
public bool IsFullyInitialized (BlockContext ec, VariableInfo vi, Location loc)
{
if (struct_info == null)
return true;
bool ok = true;
FlowBranching branching = ec.CurrentBranching;
for (int i = 0; i < struct_info.Count; i++) {
var field = struct_info.Fields [i];
if (!branching.IsStructFieldAssigned (vi, field.Name)) {
if (field.MemberDefinition is Property.BackingField) {
ec.Report.Error (843, loc,
"An automatically implemented property `{0}' must be fully assigned before control leaves the constructor. Consider calling the default struct contructor from a constructor initializer",
field.GetSignatureForError ());
} else {
ec.Report.Error (171, loc,
"Field `{0}' must be fully assigned before control leaves the constructor",
field.GetSignatureForError ());
}
ok = false;
}
}
return ok;
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:30,代码来源:flowanalysis.cs
示例17: Initialize
protected void Initialize ()
{
TypeInfo[] sub_fields = TypeInfo.SubStructInfo;
if (sub_fields != null) {
sub_info = new VariableInfo [sub_fields.Length];
for (int i = 0; i < sub_fields.Length; i++) {
if (sub_fields [i] != null)
sub_info [i] = new VariableInfo (this, sub_fields [i]);
}
} else
sub_info = new VariableInfo [0];
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:12,代码来源:flowanalysis.cs
示例18: ResolveMeta
bool ResolveMeta (BlockContext ec, ParametersCompiled ip)
{
int errors = ec.Report.Errors;
int orig_count = parameters.Count;
if (ip != null)
parameters = ip;
// Assert: orig_count != parameter.Count => orig_count == 0
if (orig_count != 0 && orig_count != parameters.Count)
throw new InternalErrorException ("parameter information mismatch");
int offset = Parent == null ? 0 : Parent.AssignableSlots;
for (int i = 0; i < orig_count; ++i) {
Parameter.Modifier mod = parameters.FixedParameters [i].ModFlags;
if ((mod & Parameter.Modifier.OUT) != Parameter.Modifier.OUT)
continue;
VariableInfo vi = new VariableInfo (ip, i, offset);
parameter_info [i].VariableInfo = vi;
offset += vi.Length;
}
ResolveMeta (ec, offset);
return ec.Report.Errors == errors;
}
开发者ID:tgiphil,项目名称:mono,代码行数:29,代码来源:statement.cs
示例19: IsDefinitelyAssigned
public bool IsDefinitelyAssigned (VariableInfo variable)
{
return variable.IsAssigned (DefiniteAssignment);
}
开发者ID:GirlD,项目名称:mono,代码行数:4,代码来源:context.cs
示例20: SetFieldAssigned
public void SetFieldAssigned (VariableInfo var, string name)
{
if (/*!var.IsParameter &&*/ IsUnreachable)
return;
var.SetStructFieldAssigned (locals, name);
}
开发者ID:yayanyang,项目名称:monodevelop,代码行数:7,代码来源:flowanalysis.cs
注:本文中的Mono.CSharp.VariableInfo类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论