本文整理汇总了C#中Mono.CSharp.FieldExpr类的典型用法代码示例。如果您正苦于以下问题:C# FieldExpr类的具体用法?C# FieldExpr怎么用?C# FieldExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FieldExpr类属于Mono.CSharp命名空间,在下文中一共展示了FieldExpr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetTemporaryField
//
// Creates temporary field in current async storey
//
public FieldExpr GetTemporaryField (TypeSpec type)
{
var f = AsyncTaskStorey.AddCapturedLocalVariable (type);
var fexpr = new FieldExpr (f, Location.Null);
fexpr.InstanceExpression = new CompilerGeneratedThis (CurrentType, Location.Null);
return fexpr;
}
开发者ID:kazol4433,项目名称:mono,代码行数:10,代码来源:codegen.cs
示例2: Emit
public override void Emit (DeclSpace parent)
{
if ((method.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) == 0) {
if (parent is Class) {
MethodBuilder mb = method_data.MethodBuilder;
mb.SetImplementationFlags (mb.GetMethodImplementationFlags () | MethodImplAttributes.Synchronized);
}
var field_info = ((EventField) method).backing_field;
FieldExpr f_expr = new FieldExpr (field_info, Location);
if ((method.ModFlags & Modifiers.STATIC) == 0)
f_expr.InstanceExpression = new CompilerGeneratedThis (field_info.Spec.MemberType, Location);
block = new ToplevelBlock (Compiler, ParameterInfo, Location);
block.AddStatement (new StatementExpression (
new CompoundAssign (Operation,
f_expr,
block.GetParameterReference (ParameterInfo[0].Name, Location),
Location)));
}
base.Emit (parent);
}
开发者ID:afaerber,项目名称:mono,代码行数:23,代码来源:property.cs
示例3: EmitHoistedFieldsInitialization
void EmitHoistedFieldsInitialization (ResolveContext rc, EmitContext ec)
{
//
// Initialize all storey reference fields by using local or hoisted variables
//
if (used_parent_storeys != null) {
foreach (StoreyFieldPair sf in used_parent_storeys) {
//
// Get instance expression of storey field
//
Expression instace_expr = GetStoreyInstanceExpression (ec);
var fs = sf.Field.Spec;
if (TypeManager.IsGenericType (instace_expr.Type))
fs = MemberCache.GetMember (instace_expr.Type, fs);
FieldExpr f_set_expr = new FieldExpr (fs, Location);
f_set_expr.InstanceExpression = instace_expr;
// TODO: CompilerAssign expression
SimpleAssign a = new SimpleAssign (f_set_expr, sf.Storey.GetStoreyInstanceExpression (ec));
if (a.Resolve (rc) != null)
a.EmitStatement (ec);
}
}
//
// Initialize hoisted `this' only once, everywhere else will be
// referenced indirectly
//
if (initialize_hoisted_this) {
rc.CurrentBlock.AddScopeStatement (new ThisInitializer (hoisted_this));
}
//
// Setting currect anonymous method to null blocks any further variable hoisting
//
AnonymousExpression ae = ec.CurrentAnonymousMethod;
ec.CurrentAnonymousMethod = null;
if (hoisted_params != null) {
EmitHoistedParameters (ec, hoisted_params);
}
ec.CurrentAnonymousMethod = ae;
}
开发者ID:rabink,项目名称:mono,代码行数:45,代码来源:anonymous.cs
示例4: GetStoreyInstanceExpression
//
// Creates storey instance expression regardless of currect IP
//
public Expression GetStoreyInstanceExpression (EmitContext ec)
{
AnonymousExpression am = ec.CurrentAnonymousMethod;
//
// Access from original block -> storey
//
if (am == null)
return Instance;
//
// Access from anonymous method implemented as a static -> storey
//
if (am.Storey == null)
return Instance;
Field f = am.Storey.GetReferencedStoreyField (this);
if (f == null) {
if (am.Storey == this) {
//
// Access from inside of same storey (S -> S)
//
return new CompilerGeneratedThis (CurrentType, Location);
}
//
// External field access
//
return Instance;
}
//
// Storey was cached to local field
//
FieldExpr f_ind = new FieldExpr (f, Location);
f_ind.InstanceExpression = new CompilerGeneratedThis (CurrentType, Location);
return f_ind;
}
开发者ID:rabink,项目名称:mono,代码行数:41,代码来源:anonymous.cs
示例5: EmitCall
protected void EmitCall(EmitContext ec, Expression binder, Arguments arguments, bool isStatement)
{
int dyn_args_count = arguments == null ? 0 : arguments.Count;
TypeExpr site_type = CreateSiteType (RootContext.ToplevelTypes.Compiler, arguments, dyn_args_count, isStatement);
FieldExpr site_field_expr = new FieldExpr (CreateSiteField (site_type), loc);
SymbolWriter.OpenCompilerGeneratedBlock (ec);
Arguments args = new Arguments (1);
args.Add (new Argument (binder));
StatementExpression s = new StatementExpression (new SimpleAssign (site_field_expr, new Invocation (new MemberAccess (site_type, "Create"), args)));
BlockContext bc = new BlockContext (ec.MemberContext, null, TypeManager.void_type);
if (s.Resolve (bc)) {
Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc), loc), s, loc);
init.Emit (ec);
}
args = new Arguments (1 + dyn_args_count);
args.Add (new Argument (site_field_expr));
if (arguments != null) {
foreach (Argument a in arguments) {
if (a is NamedArgument) {
// Name is not valid in this context
args.Add (new Argument (a.Expr, a.ArgType));
continue;
}
args.Add (a);
}
}
Expression target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, loc).Resolve (bc);
if (target != null)
target.Emit (ec);
SymbolWriter.CloseCompilerGeneratedBlock (ec);
}
开发者ID:speier,项目名称:shake,代码行数:38,代码来源:dynamic.cs
示例6: FabricateBodyStatement
void FabricateBodyStatement ()
{
//
// Delegate obj1 = backing_field
// do {
// Delegate obj2 = obj1;
// obj1 = Interlocked.CompareExchange (ref backing_field, Delegate.Combine|Remove(obj2, value), obj1);
// } while ((object)obj1 != (object)obj2)
//
var field_info = ((EventField) method).backing_field;
FieldExpr f_expr = new FieldExpr (field_info, Location);
if (!IsStatic)
f_expr.InstanceExpression = new CompilerGeneratedThis (Parent.CurrentType, Location);
var obj1 = LocalVariable.CreateCompilerGenerated (field_info.MemberType, block, Location);
var obj2 = LocalVariable.CreateCompilerGenerated (field_info.MemberType, block, Location);
block.AddStatement (new StatementExpression (new SimpleAssign (new LocalVariableReference (obj1, Location), f_expr)));
var cond = new BooleanExpression (new Binary (Binary.Operator.Inequality,
new Cast (new TypeExpression (Module.Compiler.BuiltinTypes.Object, Location), new LocalVariableReference (obj1, Location), Location),
new Cast (new TypeExpression (Module.Compiler.BuiltinTypes.Object, Location), new LocalVariableReference (obj2, Location), Location)));
var body = new ExplicitBlock (block, Location, Location);
block.AddStatement (new Do (body, cond, Location, Location));
body.AddStatement (new StatementExpression (
new SimpleAssign (new LocalVariableReference (obj2, Location), new LocalVariableReference (obj1, Location))));
var args_oper = new Arguments (2);
args_oper.Add (new Argument (new LocalVariableReference (obj2, Location)));
args_oper.Add (new Argument (block.GetParameterReference (0, Location)));
var op_method = GetOperation (Location);
var args = new Arguments (3);
args.Add (new Argument (f_expr, Argument.AType.Ref));
args.Add (new Argument (new Cast (
new TypeExpression (field_info.MemberType, Location),
new Invocation (MethodGroupExpr.CreatePredefined (op_method, op_method.DeclaringType, Location), args_oper),
Location)));
args.Add (new Argument (new LocalVariableReference (obj1, Location)));
var cas = Module.PredefinedMembers.InterlockedCompareExchange_T.Resolve (Location);
if (cas == null)
return;
body.AddStatement (new StatementExpression (new SimpleAssign (
new LocalVariableReference (obj1, Location),
new Invocation (MethodGroupExpr.CreatePredefined (cas, cas.DeclaringType, Location), args))));
}
开发者ID:bbqchickenrobot,项目名称:playscript-mono,代码行数:52,代码来源:property.cs
示例7: FabricateBodyStatement
void FabricateBodyStatement()
{
var cas = TypeManager.gen_interlocked_compare_exchange;
if (cas == null) {
var t = Module.PredefinedTypes.Interlocked.Resolve (Location);
if (t == null)
return;
var p = new ParametersImported (
new[] {
new ParameterData (null, Parameter.Modifier.REF),
new ParameterData (null, Parameter.Modifier.NONE),
new ParameterData (null, Parameter.Modifier.NONE)
},
new[] {
new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null),
new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null),
new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null),
}, false);
var filter = new MemberFilter ("CompareExchange", 1, MemberKind.Method, p, null);
cas = TypeManager.gen_interlocked_compare_exchange = TypeManager.GetPredefinedMethod (t, filter, Location);
}
//
// Delegate obj1 = backing_field
// do {
// Delegate obj2 = obj1;
// obj1 = Interlocked.CompareExchange (ref backing_field, Delegate.Combine|Remove(obj2, value), obj1);
// } while (obj1 != obj2)
//
var field_info = ((EventField) method).backing_field;
FieldExpr f_expr = new FieldExpr (field_info, Location);
if (!IsStatic)
f_expr.InstanceExpression = new CompilerGeneratedThis (Parent.CurrentType, Location);
var obj1 = LocalVariable.CreateCompilerGenerated (field_info.MemberType, block, Location);
var obj2 = LocalVariable.CreateCompilerGenerated (field_info.MemberType, block, Location);
block.AddStatement (new StatementExpression (new SimpleAssign (new LocalVariableReference (obj1, Location), f_expr)));
var cond = new BooleanExpression (new Binary (Binary.Operator.Inequality,
new LocalVariableReference (obj1, Location), new LocalVariableReference (obj2, Location), Location));
var body = new ExplicitBlock (block, Location, Location);
block.AddStatement (new Do (body, cond, Location));
body.AddStatement (new StatementExpression (
new SimpleAssign (new LocalVariableReference (obj2, Location), new LocalVariableReference (obj1, Location))));
var args_oper = new Arguments (2);
args_oper.Add (new Argument (new LocalVariableReference (obj2, Location)));
args_oper.Add (new Argument (block.GetParameterReference (0, Location)));
var args = new Arguments (3);
args.Add (new Argument (f_expr, Argument.AType.Ref));
args.Add (new Argument (new Cast (
new TypeExpression (field_info.MemberType, Location),
new Invocation (MethodGroupExpr.CreatePredefined (Operation, Operation.DeclaringType, Location), args_oper),
Location)));
args.Add (new Argument (new LocalVariableReference (obj1, Location)));
body.AddStatement (new StatementExpression (new SimpleAssign (
new LocalVariableReference (obj1, Location),
new Invocation (MethodGroupExpr.CreatePredefined (cas, cas.DeclaringType, Location), args))));
}
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:67,代码来源:property.cs
示例8: DoEmit
protected override void DoEmit (EmitContext ec)
{
Expression source;
if (parent == null)
source = new CompilerGeneratedThis (ec.CurrentType, loc);
else {
source = new FieldExpr (parent.HoistedThis.Field, Location.Null) {
InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, Location.Null)
};
}
hoisted_this.EmitAssign (ec, source, false, false);
}
开发者ID:erik-kallen,项目名称:NRefactory,代码行数:14,代码来源:anonymous.cs
示例9: ResolveMemberAccess
public override MemberExpr ResolveMemberAccess (EmitContext ec, Expression left, Location loc,
SimpleName original)
{
//
// If the event is local to this class, we transform ourselves into a FieldExpr
//
if (EventInfo.DeclaringType == ec.ContainerType ||
TypeManager.IsNestedChildOf(ec.ContainerType, EventInfo.DeclaringType)) {
EventField mi = TypeManager.GetEventField (EventInfo);
if (mi != null) {
if (!ec.IsInObsoleteScope)
mi.CheckObsoleteness (loc);
if ((mi.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) != 0 && !ec.IsInCompoundAssignment)
Error_AssignmentEventOnly ();
FieldExpr ml = new FieldExpr (mi.FieldBuilder, loc);
InstanceExpression = null;
return ml.ResolveMemberAccess (ec, left, loc, original);
}
}
if (left is This && !ec.IsInCompoundAssignment)
Error_AssignmentEventOnly ();
return base.ResolveMemberAccess (ec, left, loc, original);
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:31,代码来源:ecore.cs
示例10: EmitFieldInitializers
//
// Emits the instance field initializers
//
public bool EmitFieldInitializers (EmitContext ec)
{
ArrayList fields;
ILGenerator ig = ec.ig;
Expression instance_expr;
if (ec.IsStatic){
fields = initialized_static_fields;
instance_expr = null;
} else {
fields = initialized_fields;
instance_expr = new This (Location.Null).Resolve (ec);
}
if (fields == null)
return true;
foreach (Field f in fields){
Expression e = f.GetInitializerExpression (ec);
if (e == null)
return false;
Location l = f.Location;
FieldExpr fe = new FieldExpr (f.FieldBuilder, l);
fe.InstanceExpression = instance_expr;
Expression a = new Assign (fe, e, l);
a = a.Resolve (ec);
if (a == null)
return false;
if (a is ExpressionStatement)
((ExpressionStatement) a).EmitStatement (ec);
else {
throw new Exception ("Assign.Resolve returned a non ExpressionStatement");
}
}
return true;
}
开发者ID:emtees,项目名称:old-code,代码行数:43,代码来源:class.cs
示例11: Resolve
public override bool Resolve (BlockContext ec)
{
TypeExpression storey_type_expr = new TypeExpression (host.Definition, loc);
List<Expression> init = null;
if (host.hoisted_this != null) {
init = new List<Expression> (host.hoisted_params == null ? 1 : host.HoistedParameters.Count + 1);
HoistedThis ht = host.hoisted_this;
FieldExpr from = new FieldExpr (ht.Field, loc);
from.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc);
init.Add (new ElementInitializer (ht.Field.Name, from, loc));
}
if (host.hoisted_params != null) {
if (init == null)
init = new List<Expression> (host.HoistedParameters.Count);
for (int i = 0; i < host.hoisted_params.Count; ++i) {
HoistedParameter hp = (HoistedParameter) host.hoisted_params [i];
HoistedParameter hp_cp = (HoistedParameter) host.hoisted_params_copy [i];
FieldExpr from = new FieldExpr (hp_cp.Field, loc);
from.InstanceExpression = new CompilerGeneratedThis (ec.CurrentType, loc);
init.Add (new ElementInitializer (hp.Field.Name, from, loc));
}
}
if (init != null) {
new_storey = new NewInitialize (storey_type_expr, null,
new CollectionOrObjectInitializers (init, loc), loc);
} else {
new_storey = new New (storey_type_expr, null, loc);
}
new_storey = new_storey.Resolve (ec);
if (new_storey != null)
new_storey = Convert.ImplicitConversionRequired (ec, new_storey, host_method.MemberType, loc);
ec.CurrentBranching.CurrentUsageVector.Goto ();
return true;
}
开发者ID:constructor-igor,项目名称:cudafy,代码行数:41,代码来源:iterators.cs
示例12: GetFieldExpression
//
// Creates field access expression for hoisted variable
//
protected FieldExpr GetFieldExpression (EmitContext ec)
{
if (ec.CurrentAnonymousMethod == null || ec.CurrentAnonymousMethod.Storey == null) {
if (cached_outer_access != null)
return cached_outer_access;
//
// When setting top-level hoisted variable in generic storey
// change storey generic types to method generic types (VAR -> MVAR)
//
cached_outer_access = storey.MemberName.IsGeneric ?
new FieldExpr (field.FieldBuilder, storey.Instance.Type, field.Location) :
new FieldExpr (field.FieldBuilder, field.Location);
cached_outer_access.InstanceExpression = storey.GetStoreyInstanceExpression (ec);
return cached_outer_access;
}
FieldExpr inner_access;
if (cached_inner_access != null) {
inner_access = (FieldExpr) cached_inner_access [ec.CurrentAnonymousMethod];
} else {
inner_access = null;
cached_inner_access = new Hashtable (4);
}
if (inner_access == null) {
inner_access = field.Parent.MemberName.IsGeneric ?
new FieldExpr (field.FieldBuilder, field.Parent.CurrentType, field.Location) :
new FieldExpr (field.FieldBuilder, field.Location);
inner_access.InstanceExpression = storey.GetStoreyInstanceExpression (ec);
cached_inner_access.Add (ec.CurrentAnonymousMethod, inner_access);
}
return inner_access;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:40,代码来源:anonymous.cs
示例13: Resolve
public override bool Resolve (BlockContext ec)
{
TypeExpression storey_type_expr = new TypeExpression (host.TypeBuilder, loc);
ArrayList init = null;
if (host.hoisted_this != null) {
init = new ArrayList (host.hoisted_params == null ? 1 : host.HoistedParameters.Count + 1);
HoistedThis ht = host.hoisted_this;
FieldExpr from = new FieldExpr (ht.Field.FieldBuilder, loc);
from.InstanceExpression = CompilerGeneratedThis.Instance;
init.Add (new ElementInitializer (ht.Field.Name, from, loc));
}
if (host.hoisted_params != null) {
if (init == null)
init = new ArrayList (host.HoistedParameters.Count);
for (int i = 0; i < host.hoisted_params.Count; ++i) {
HoistedParameter hp = (HoistedParameter) host.hoisted_params [i];
HoistedParameter hp_cp = (HoistedParameter) host.hoisted_params_copy [i];
FieldExpr from = new FieldExpr (hp_cp.Field.FieldBuilder, loc);
from.InstanceExpression = CompilerGeneratedThis.Instance;
init.Add (new ElementInitializer (hp.Field.Name, from, loc));
}
}
if (init != null) {
new_storey = new NewInitialize (storey_type_expr, null,
new CollectionOrObjectInitializers (init, loc), loc);
} else {
new_storey = new New (storey_type_expr, null, loc);
}
new_storey = new_storey.Resolve (ec);
if (new_storey != null)
new_storey = Convert.ImplicitConversionRequired (ec, new_storey, host_method.MemberType, loc);
if (TypeManager.int_interlocked_compare_exchange == null) {
Type t = TypeManager.CoreLookupType (ec.Compiler, "System.Threading", "Interlocked", Kind.Class, true);
if (t != null) {
TypeManager.int_interlocked_compare_exchange = TypeManager.GetPredefinedMethod (
t, "CompareExchange", loc, TypeManager.int32_type,
TypeManager.int32_type, TypeManager.int32_type);
}
}
ec.CurrentBranching.CurrentUsageVector.Goto ();
return true;
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:50,代码来源:iterators.cs
示例14: EmitCall
//.........这里部分代码省略.........
}
} else {
d = null;
}
var site_type_decl = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec, new TypeArguments (del_type), loc);
var field = site_container.CreateCallSiteField (site_type_decl, loc);
if (field == null)
return;
if (del_type_instance_access == null) {
var dt = d.CurrentType.DeclaringType.MakeGenericType (module, context_mvars.Types);
del_type_instance_access = new TypeExpression (MemberCache.GetMember (dt, d.CurrentType), loc);
}
var instanceAccessExprType = new GenericTypeExpr (module.PredefinedTypes.CallSiteGeneric.TypeSpec,
new TypeArguments (del_type_instance_access), loc);
if (instanceAccessExprType.ResolveAsType (ec.MemberContext) == null)
return;
bool inflate_using_mvar = context_mvars != null && ec.IsAnonymousStoreyMutateRequired;
TypeSpec gt;
if (inflate_using_mvar || context_mvars == null) {
gt = site_container.CurrentType;
} else {
gt = site_container.CurrentType.MakeGenericType (module, context_mvars.Types);
}
// When site container already exists the inflated version has to be
// updated manually to contain newly created field
if (gt is InflatedTypeSpec && site_container.AnonymousMethodsCounter > 1) {
var tparams = gt.MemberDefinition.TypeParametersCount > 0 ? gt.MemberDefinition.TypeParameters : TypeParameterSpec.EmptyTypes;
var inflator = new TypeParameterInflator (module, gt, tparams, gt.TypeArguments);
gt.MemberCache.AddMember (field.InflateMember (inflator));
}
FieldExpr site_field_expr = new FieldExpr (MemberCache.GetMember (gt, field), loc);
BlockContext bc = new BlockContext (ec.MemberContext, null, ec.BuiltinTypes.Void);
Arguments args = new Arguments (1);
args.Add (new Argument (binder));
StatementExpression s = new StatementExpression (new SimpleAssign (site_field_expr, new Invocation (new MemberAccess (instanceAccessExprType, "Create"), args)));
using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {
var conditionalAccessReceiver = IsConditionalAccessReceiver;
var ca = ec.ConditionalAccess;
if (conditionalAccessReceiver) {
ec.ConditionalAccess = new ConditionalAccessContext (type, ec.DefineLabel ()) {
Statement = isStatement
};
//
// Emit conditional access expressions before dynamic call
// is initialized. It pushes site_field_expr on stack before
// the actual instance argument is emited which would cause
// jump from non-empty stack.
//
EmitConditionalAccess (ec);
}
if (s.Resolve (bc)) {
Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc)), s, loc);
init.Emit (ec);
}
args = new Arguments (1 + dyn_args_count);
args.Add (new Argument (site_field_expr));
if (arguments != null) {
int arg_pos = 1;
foreach (Argument a in arguments) {
if (a is NamedArgument) {
// Name is not valid in this context
args.Add (new Argument (a.Expr, a.ArgType));
} else {
args.Add (a);
}
if (inflate_using_mvar && a.Type != targs[arg_pos].Type)
a.Expr.Type = targs[arg_pos].Type;
++arg_pos;
}
}
var target = new DelegateInvocation (new MemberAccess (site_field_expr, "Target", loc).Resolve (bc), args, false, loc).Resolve (bc);
if (target != null) {
target.Emit (ec);
}
if (conditionalAccessReceiver) {
ec.CloseConditionalAccess (!isStatement && type.IsNullableType ? type : null);
ec.ConditionalAccess = ca;
}
}
}
开发者ID:caomw,项目名称:mono,代码行数:101,代码来源:dynamic.cs
示例15: EmitCallWithInvoke
protected void EmitCallWithInvoke (EmitContext ec, Expression binder, Arguments arguments, bool isStatement)
{
var module = ec.Module;
var site_container = ec.CreateDynamicSite ();
BlockContext bc = new BlockContext (ec.MemberContext, null, ec.BuiltinTypes.Void);
FieldExpr site_field_expr = null;
StatementExpression s = null;
// create call site
var call_site = binder;
if (call_site != null) {
// resolve call site
call_site = call_site.Resolve(bc);
// create field for call site
var site_type_decl = call_site.Type;
var field = site_container.CreateCallSiteField (new TypeExpression(site_type_decl, loc), loc);
if (field == null) {
throw new InvalidOperationException("Could not create call site field");
}
// ???
bool inflate_using_mvar = context_mvars != null && ec.IsAnonymousStoreyMutateRequired;
// ???
TypeSpec gt;
if (inflate_using_mvar || context_mvars == null) {
gt = site_container.CurrentType;
} else {
gt = site_container.CurrentType.MakeGenericType (module, context_mvars.Types);
}
// When site container already exists the inflated version has to be
// updated manually to contain newly created field
if (gt is InflatedTypeSpec && site_container.AnonymousMethodsCounter > 1) {
var tparams = gt.MemberDefinition.TypeParametersCount > 0 ? gt.MemberDefinition.TypeParameters : TypeParameterSpec.EmptyTypes;
var inflator = new TypeParameterInflator (module, gt, tparams, gt.TypeArguments);
gt.MemberCache.AddMember (field.InflateMember (inflator));
}
site_field_expr = new FieldExpr (MemberCache.GetMember (gt, field), loc);
s = new StatementExpression (new SimpleAssign (site_field_expr, call_site));
}
using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) {
if (s!= null && s.Resolve (bc)) {
Statement init = new If (new Binary (Binary.Operator.Equality, site_field_expr, new NullLiteral (loc)), s, loc);
init.Emit (ec);
}
// remove dynamics from argument list
arguments.CastDynamicArgs(bc);
IDynamicCallSite dynamicCallSite = (IDynamicCallSite)this.binder;
Expression target = dynamicCallSite.InvokeCallSite(bc, site_field_expr, arguments, type, isStatement);
if (target != null)
target = target.Resolve(bc);
if (target != null)
{
var statement = target as ExpressionStatement;
if (isStatement && statement != null)
{
statement.EmitStatement(ec);
}
else
{
if (!isStatement && (target.Type != type)) {
// PlayScript: If doing an invoke, we have to cast the return type to the type expected by the expression..
target = new Cast(new TypeExpression(type, loc), target, loc).Resolve (bc);
}
target.Emit(ec);
}
}
}
}
开发者ID:rlfqudxo,项目名称:playscript-mono,代码行数:84,代码来源:dynamic.cs
示例16: DoResolve
protected override Expression DoResolve (ResolveContext rc)
{
target = new FieldExpr (field, loc);
source = rc.CurrentBlock.ParametersBlock.GetParameterInfo (parameter).CreateReferenceExpression (rc, loc);
return base.DoResolve (rc);
}
开发者ID:nobled,项目名称:mono,代码行数:6,代码来源:assign.cs
示例17: ResolveMemberAccess
public override MemberExpr ResolveMemberAccess(ResolveContext ec, Expression left, Location loc,
SimpleName original)
{
//
// If the event is local to this class, we transform ourselves into a FieldExpr
//
if (spec.DeclaringType == ec.CurrentType ||
TypeManager.IsNestedChildOf(ec.CurrentType, spec.DeclaringType)) {
// TODO: Breaks dynamic binder as currect context fields are imported and not compiled
EventField mi = spec.MemberDefinition as EventField;
if (mi != null && mi.HasBackingField) {
mi.SetIsUsed ();
if (!ec.IsObsolete)
mi.CheckObsoleteness (loc);
if ((mi.ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) != 0 && !ec.HasSet (ResolveContext.Options.CompoundAssignmentScope))
Error_AssignmentEventOnly (ec);
FieldExpr ml = new FieldExpr (mi.BackingField, loc);
InstanceExpression = null;
return ml.ResolveMemberAccess (ec, left, loc, original);
}
}
if (left is This && !ec.HasSet (ResolveContext.Options.CompoundAssignmentScope))
Error_AssignmentEventOnly (ec);
return base.ResolveMemberAccess (ec, left, loc, original);
}
开发者ID:speier,项目名称:shake,代码行数:34,代码来源:ecore.cs
示例18: Resolve
public override bool Resolve(BlockContext ec)
{
TypeExpression storey_type_expr = new TypeExpression (host.Definition, loc);
List<Expression> init = null;
if (host.hoisted_this != null) {
init = new List<Expression> (host.hoisted_params == null ? 1 : host.HoistedParameters.Count + 1);
HoistedThis ht = host.hoisted_this;
FieldExpr from = new FieldExpr (ht.Field, loc);
from.InstanceExpression = CompilerGeneratedThis.Instance;
init.Add (new ElementInitializer (ht.Field.Name, from, loc));
}
if (host.hoisted_params != null) {
if (init == null)
init = new List<Expression> (host.HoistedParameters.Count);
for (int i = 0; i < host.hoisted_params.Count; ++i) {
HoistedParameter hp = (HoistedParameter) host.hoisted_params [i];
HoistedParameter hp_cp = (HoistedParameter) host.hoisted_params_copy [i];
FieldExpr from = new FieldExpr (hp_cp.Field, loc);
from.InstanceExpression = CompilerGeneratedThis.Instance;
init.Add (new ElementInitializer (hp.Field.Name, from, loc));
}
}
if (init != null) {
new_storey = new NewInitialize (storey_type_expr, null,
new CollectionOrObjectInitializers (init, loc), loc);
} else {
new_storey = new New (storey_type_expr, null, loc);
}
new_storey = new_storey.Resolve (ec);
if (new_storey != null)
new_storey = Convert.ImplicitConversionRequired (ec, new_storey, host_method.MemberType, loc);
if (TypeManager.int_interlocked_compare_exchange == null) {
TypeSpec t = TypeManager.CoreLookupType (ec.Compiler, "System.Threading", "Interlocked", MemberKind.Class, true);
if (t != null) {
var p = ParametersCompiled.CreateFullyResolved (
new[] {
new ParameterData (null, Parameter.Modifier.REF),
new ParameterData (null, Parameter.Modifier.NONE),
new ParameterData (null, Parameter.Modifier.NONE)
},
new[] {
TypeManager.int32_type, TypeManager.int32_type, TypeManager.int32_type
}
);
var f = new MemberFilter ("CompareExchange", 0, MemberKind.Method, p, TypeManager.int32_type);
TypeManager.int_interlocked_compare_exchange = TypeManager.GetPredefinedMethod (t, f, loc);
}
}
ec.CurrentBranching.CurrentUsageVector.Goto ();
return true;
}
开发者ID:speier,项目名称:shake,代码行数:59,代码来源:iterators.cs
示例19: CreateAutomaticProperty
void CreateAutomaticProperty ()
{
// Create backing field
backing_field = new BackingField (this, Initializer != null && Set == null);
if (!backing_field.Define ())
return;
if (Initializer != null) {
backing_field.Initializer = Initializer;
Parent.RegisterFieldForInitialization (backing_field, new FieldInitializer (backing_field, Initializer, Location));
backing_field.ModFlags |= Modifiers.READONLY;
}
Parent.PartialContainer.Members.Add (backing_field);
FieldExpr fe = new FieldExpr (backing_field, Location);
if ((backing_field.ModFlags & Modifiers.STATIC) == 0)
fe.InstanceExpression = new CompilerGeneratedThis (Parent.CurrentType, Location);
//
// Create get block but we careful with location to
// emit only single sequence point per accessor. This allow
// to set a breakpoint on it even with no user code
//
Get.Block = new ToplevelBlock (Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null);
Return r = new Return (fe, Get.Location);
Get.Block.AddStatement (r);
Get.ModFlags |= Modifiers.COMPILER_GENERATED;
// Create set block
if (Set != null) {
Set.Block = new ToplevelBlock (Compiler, Set.ParameterInfo, Location.Null);
Assign a = new SimpleAssign (fe, new SimpleName ("value", Location.Null), Location.Null);
Set.Block.AddStatement (new StatementExpression (a, Set.Location));
Set.ModFlags |= Modifiers.COMPILER_GENERATED;
}
}
开发者ID:frje,项目名称:SharpLang,代码行数:37,代码来源:property.cs
示例20: CreateAutomaticProperty
void CreateAutomaticProperty ()
{
// Create backing field
Field field = new BackingField (this);
if (!field.Define ())
return;
Parent.PartialContainer.Members.Add (field);
FieldExpr fe = new FieldExpr (field, Location);
if ((field.ModFlags & Modifiers.STATIC) == 0)
fe.InstanceExpression = new CompilerGeneratedThis (Parent.CurrentType, Location);
//
// Create get block but we careful with location to
// emit only single sequence point per accessor. This allow
// to set a breakpoint on it even with no user code
//
Get.Block = new ToplevelBlock (Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location.Null);
Return r = new Return (fe, Get.Location);
Get.Block.AddStatement (r);
// Create set block
Set.Block = new ToplevelBlock (Compiler, Set.ParameterInfo, Location.Null);
Assign a = new SimpleAssign (fe, new SimpleName ("value", Location.Null), Location.Null);
Set.Block.AddStatement (new StatementExpression (a, Set.Location));
}
开发者ID:bbqchickenrobot,项目名称:playscript-mono,代码行数:27,代码来源:property.cs
注:本文中的Mono.CSharp.FieldExpr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论