本文整理汇总了C#中Mono.CSharp.BlockContext类的典型用法代码示例。如果您正苦于以下问题:C# BlockContext类的具体用法?C# BlockContext怎么用?C# BlockContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BlockContext类属于Mono.CSharp命名空间,在下文中一共展示了BlockContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Resolve
public override bool Resolve (BlockContext ec)
{
expr = expr.Resolve (ec);
if (expr == null)
return false;
Report.Debug (64, "RESOLVE YIELD #1", this, ec, expr, expr.GetType (),
ec.CurrentAnonymousMethod, ec.CurrentIterator);
if (!CheckContext (ec, loc))
return false;
iterator = ec.CurrentIterator;
if (expr.Type != iterator.OriginalIteratorType) {
expr = Convert.ImplicitConversionRequired (
ec, expr, iterator.OriginalIteratorType, loc);
if (expr == null)
return false;
}
if (!ec.CurrentBranching.CurrentUsageVector.IsUnreachable)
unwind_protect = ec.CurrentBranching.AddResumePoint (this, loc, out resume_pc);
return true;
}
开发者ID:Tak,项目名称:monodevelop-novell,代码行数:25,代码来源:iterators.cs
示例2: CreateExpressionTree
protected override Expression CreateExpressionTree (ResolveContext ec, Type delegate_type)
{
if (ec.IsInProbingMode)
return this;
BlockContext bc = new BlockContext (ec.MemberContext, ec.CurrentBlock.Explicit, TypeManager.void_type);
Expression args = Parameters.CreateExpressionTree (bc, loc);
Expression expr = Block.CreateExpressionTree (ec);
if (expr == null)
return null;
Arguments arguments = new Arguments (2);
arguments.Add (new Argument (expr));
arguments.Add (new Argument (args));
return CreateExpressionFactoryCall (ec, "Lambda",
new TypeArguments (new TypeExpression (delegate_type, loc)),
arguments);
}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:18,代码来源:lambda.cs
示例3: DoResolve
protected override bool DoResolve(BlockContext ec)
{
//
// When delegate returns void, only expression statements can be used
//
if (ec.ReturnType == TypeManager.void_type) {
Expr = Expr.Resolve (ec);
if (Expr == null)
return false;
statement = Expr as ExpressionStatement;
if (statement == null)
Expr.Error_InvalidExpressionStatement (ec);
return true;
}
return base.DoResolve (ec);
}
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:19,代码来源:lambda.cs
示例4: ResolveUnreachable
/// <summary>
/// We already know that the statement is unreachable, but we still
/// need to resolve it to catch errors.
/// </summary>
public virtual bool ResolveUnreachable (BlockContext ec, bool warn)
{
//
// This conflicts with csc's way of doing this, but IMHO it's
// the right thing to do.
//
// If something is unreachable, we still check whether it's
// correct. This means that you cannot use unassigned variables
// in unreachable code, for instance.
//
if (warn)
ec.Report.Warning (162, 2, loc, "Unreachable code detected");
ec.StartFlowBranching (FlowBranching.BranchingType.Block, loc);
bool ok = Resolve (ec);
ec.KillFlowBranching ();
return ok;
}
开发者ID:alisci01,项目名称:mono,代码行数:24,代码来源:statement.cs
示例5: CreateExpressionTree
protected override Expression CreateExpressionTree (ResolveContext ec, TypeSpec delegate_type)
{
if (ec.IsInProbingMode)
return this;
BlockContext bc = new BlockContext (ec.MemberContext, ec.ConstructorBlock, ec.BuiltinTypes.Void) {
CurrentAnonymousMethod = ec.CurrentAnonymousMethod
};
Expression args = Parameters.CreateExpressionTree (bc, loc);
Expression expr = Block.CreateExpressionTree (ec);
if (expr == null)
return null;
Arguments arguments = new Arguments (2);
arguments.Add (new Argument (expr));
arguments.Add (new Argument (args));
return CreateExpressionFactoryCall (ec, "Lambda",
new TypeArguments (new TypeExpression (delegate_type, loc)),
arguments);
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:21,代码来源:lambda.cs
示例6: FieldInitializerContext
public FieldInitializerContext (IMemberContext mc, BlockContext constructorContext)
: base (mc, null, constructorContext.ReturnType)
{
flags |= Options.FieldInitializerScope | Options.ConstructorScope;
this.ctor_block = constructorContext.CurrentBlock.Explicit;
}
开发者ID:dyxu,项目名称:vimrc,代码行数:6,代码来源:assign.cs
示例7: GetCompletions
public string [] GetCompletions (string input, out string prefix)
{
prefix = "";
if (input == null || input.Length == 0)
return null;
lock (evaluator_lock){
if (!inited)
Init ();
bool partial_input;
CSharpParser parser = ParseString (ParseMode.GetCompletions, input, out partial_input);
if (parser == null){
return null;
}
Class parser_result = parser.InteractiveResult;
#if NET_4_0
var access = AssemblyBuilderAccess.RunAndCollect;
#else
var access = AssemblyBuilderAccess.Run;
#endif
var a = new AssemblyDefinitionDynamic (module, "completions");
a.Create (AppDomain.CurrentDomain, access);
module.SetDeclaringAssembly (a);
// Need to setup MemberCache
parser_result.CreateContainer ();
var method = parser_result.Members[0] as Method;
BlockContext bc = new BlockContext (method, method.Block, ctx.BuiltinTypes.Void);
try {
method.Block.Resolve (null, bc, method);
} catch (CompletionResult cr) {
prefix = cr.BaseText;
return cr.Result;
}
}
return null;
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:42,代码来源:eval.cs
示例8: GetCompletions
public static string [] GetCompletions (string input, out string prefix)
{
prefix = "";
if (input == null || input.Length == 0)
return null;
lock (evaluator_lock){
if (!inited)
Init ();
bool partial_input;
CSharpParser parser = ParseString (ParseMode.GetCompletions, input, out partial_input);
if (parser == null){
if (CSharpParser.yacc_verbose_flag != 0)
Console.WriteLine ("DEBUG: No completions available");
return null;
}
Class parser_result = parser.InteractiveResult;
try {
var a = new AssemblyDefinitionDynamic (RootContext.ToplevelTypes, "temp");
a.Create (AppDomain.CurrentDomain, AssemblyBuilderAccess.Run);
RootContext.ToplevelTypes.SetDeclaringAssembly (a);
RootContext.ToplevelTypes.CreateType ();
RootContext.ToplevelTypes.Define ();
parser_result.CreateType ();
parser_result.Define ();
if (ctx.Report.Errors != 0)
return null;
MethodOrOperator method = null;
foreach (MemberCore member in parser_result.Methods){
if (member.Name != "Host")
continue;
method = (MethodOrOperator) member;
break;
}
if (method == null)
throw new InternalErrorException ("did not find the the Host method");
BlockContext bc = new BlockContext (method, method.Block, method.ReturnType);
try {
method.Block.Resolve (null, bc, method);
} catch (CompletionResult cr){
prefix = cr.BaseText;
return cr.Result;
}
} finally {
parser.undo.ExecuteUndo ();
}
}
return null;
}
开发者ID:keith512,项目名称:mono,代码行数:58,代码来源:eval.cs
示例9: 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
示例10: ResolveFieldInitializers
public void ResolveFieldInitializers (BlockContext ec)
{
Debug.Assert (!IsPartialPart);
if (ec.IsStatic) {
if (initialized_static_fields == null)
return;
bool has_complex_initializer = !ec.Module.Compiler.Settings.Optimize;
int i;
ExpressionStatement [] init = new ExpressionStatement [initialized_static_fields.Count];
for (i = 0; i < initialized_static_fields.Count; ++i) {
FieldInitializer fi = initialized_static_fields [i];
ExpressionStatement s = fi.ResolveStatement (ec);
if (s == null) {
s = EmptyExpressionStatement.Instance;
} else if (!fi.IsSideEffectFree) {
has_complex_initializer = true;
}
init [i] = s;
}
for (i = 0; i < initialized_static_fields.Count; ++i) {
FieldInitializer fi = initialized_static_fields [i];
//
// Need special check to not optimize code like this
// static int a = b = 5;
// static int b = 0;
//
if (!has_complex_initializer && fi.IsDefaultInitializer)
continue;
ec.AssignmentInfoOffset += fi.AssignmentOffset;
ec.CurrentBlock.AddScopeStatement (new StatementExpression (init [i]));
}
return;
}
if (initialized_fields == null)
return;
for (int i = 0; i < initialized_fields.Count; ++i) {
FieldInitializer fi = initialized_fields [i];
//
// Clone before resolving otherwise when field initializer is needed
// in more than 1 constructor any resolve after the initial one would
// only took the resolved expression which is problem for expressions
// that generate extra expressions or code during Resolve phase
//
var cloned = fi.Clone (new CloneContext ());
ExpressionStatement s = fi.ResolveStatement (ec);
if (s == null) {
initialized_fields [i] = new FieldInitializer (fi.Field, ErrorExpression.Instance, Location.Null);
continue;
}
//
// Field is re-initialized to its default value => removed
//
if (fi.IsDefaultInitializer && Kind != MemberKind.Struct && ec.Module.Compiler.Settings.Optimize)
continue;
ec.AssignmentInfoOffset += fi.AssignmentOffset;
ec.CurrentBlock.AddScopeStatement (new StatementExpression (s));
initialized_fields [i] = (FieldInitializer) cloned;
}
}
开发者ID:razzfazz,项目名称:mono,代码行数:71,代码来源:class.cs
示例11: CreateExpressionTreeVariable
public ExpressionStatement CreateExpressionTreeVariable (BlockContext ec)
{
if ((modFlags & Modifier.RefOutMask) != 0)
ec.Report.Error (1951, Location, "An expression tree parameter cannot use `ref' or `out' modifier");
expr_tree_variable = TemporaryVariableReference.Create (ResolveParameterExpressionType (ec, Location).Type, ec.CurrentBlock.ParametersBlock, Location);
expr_tree_variable = (TemporaryVariableReference) expr_tree_variable.Resolve (ec);
Arguments arguments = new Arguments (2);
arguments.Add (new Argument (new TypeOf (parameter_type, Location)));
arguments.Add (new Argument (new StringConstant (ec.BuiltinTypes, Name, Location)));
return new SimpleAssign (ExpressionTreeVariableReference (),
Expression.CreateExpressionFactoryCall (ec, "Parameter", null, arguments, Location));
}
开发者ID:bl8,项目名称:mono,代码行数:14,代码来源:parameter.cs
示例12: Emit
//
// Emits the code
//
public void Emit (TypeDefinition parent)
{
DefineOverride (parent);
var mc = (IMemberContext) method;
method.ParameterInfo.ApplyAttributes (mc, MethodBuilder);
ToplevelBlock block = method.Block;
if (block != null) {
BlockContext bc = new BlockContext (mc, block, method.ReturnType);
if (block.Resolve (null, bc, method)) {
debug_builder = member.Parent.CreateMethodSymbolEntry ();
EmitContext ec = method.CreateEmitContext (MethodBuilder.GetILGenerator (), debug_builder);
block.Emit (ec);
}
}
}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:22,代码来源:method.cs
示例13: Compatible
public AnonymousExpression Compatible (ResolveContext ec, AnonymousExpression ae)
{
if (block.Resolved)
return this;
// TODO: Implement clone
BlockContext aec = new BlockContext (ec, block, ReturnType);
aec.CurrentAnonymousMethod = ae;
var am = this as AnonymousMethodBody;
if (ec.HasSet (ResolveContext.Options.InferReturnType) && am != null) {
am.ReturnTypeInference = new TypeInferenceContext ();
}
var bc = ec as BlockContext;
if (bc != null) {
aec.AssignmentInfoOffset = bc.AssignmentInfoOffset;
aec.EnclosingLoop = bc.EnclosingLoop;
aec.EnclosingLoopOrSwitch = bc.EnclosingLoopOrSwitch;
aec.Switch = bc.Switch;
}
var errors = ec.Report.Errors;
bool res = Block.Resolve (aec);
if (res && errors == ec.Report.Errors) {
MarkReachable (new Reachability ());
if (!CheckReachableExit (ec.Report)) {
return null;
}
if (bc != null)
bc.AssignmentInfoOffset = aec.AssignmentInfoOffset;
}
if (am != null && am.ReturnTypeInference != null) {
am.ReturnTypeInference.FixAllTypes (ec);
ReturnType = am.ReturnTypeInference.InferredTypeArguments [0];
am.ReturnTypeInference = null;
//
// If e is synchronous the inferred return type is T
// If e is asynchronous and the body of F is either an expression classified as nothing
// or a statement block where no return statements have expressions, the inferred return type is Task
// If e is async and has an inferred result type T, the inferred return type is Task<T>
//
if (block.IsAsync && ReturnType != null) {
ReturnType = ReturnType.Kind == MemberKind.Void ?
ec.Module.PredefinedTypes.Task.TypeSpec :
ec.Module.PredefinedTypes.TaskGeneric.TypeSpec.MakeGenericType (ec, new [] { ReturnType });
}
}
if (res && errors != ec.Report.Errors)
return null;
return res ? this : null;
}
开发者ID:erik-kallen,项目名称:NRefactory,代码行数:62,代码来源:anonymous.cs
示例14: CreateExpressionTree
public Expression CreateExpressionTree (BlockContext ec, Location loc)
{
var initializers = new ArrayInitializer (Count, loc);
foreach (Parameter p in FixedParameters) {
//
// Each parameter expression is stored to local variable
// to save some memory when referenced later.
//
StatementExpression se = new StatementExpression (p.CreateExpressionTreeVariable (ec), Location.Null);
if (se.Resolve (ec)) {
ec.CurrentBlock.AddScopeStatement (new TemporaryVariableReference.Declarator (p.ExpressionTreeVariableReference ()));
ec.CurrentBlock.AddScopeStatement (se);
}
initializers.Add (p.ExpressionTreeVariableReference ());
}
return new ArrayCreation (
Parameter.ResolveParameterExpressionType (ec, loc),
initializers, loc);
}
开发者ID:bl8,项目名称:mono,代码行数:21,代码来源:parameter.cs
示例15: GetCompletions
public static string [] GetCompletions (string input, out string prefix)
{
prefix = "";
if (input == null || input.Length == 0)
return null;
lock (evaluator_lock){
if (!inited)
Init ();
bool partial_input;
CSharpParser parser = ParseString (ParseMode.GetCompletions, input, out partial_input);
if (parser == null){
if (CSharpParser.yacc_verbose_flag != 0)
Console.WriteLine ("DEBUG: No completions available");
return null;
}
Class parser_result = parser.InteractiveResult as Class;
if (parser_result == null){
if (CSharpParser.yacc_verbose_flag != 0)
Console.WriteLine ("Do not know how to cope with !Class yet");
return null;
}
try {
RootContext.ResolveTree ();
if (ctx.Report.Errors != 0)
return null;
RootContext.PopulateTypes ();
if (ctx.Report.Errors != 0)
return null;
MethodOrOperator method = null;
foreach (MemberCore member in parser_result.Methods){
if (member.Name != "Host")
continue;
method = (MethodOrOperator) member;
break;
}
if (method == null)
throw new InternalErrorException ("did not find the the Host method");
BlockContext bc = new BlockContext (method, method.Block, method.ReturnType);
try {
method.Block.Resolve (null, bc, method);
} catch (CompletionResult cr){
prefix = cr.BaseText;
return cr.Result;
}
} finally {
parser.undo.ExecuteUndo ();
}
}
return null;
}
开发者ID:silk,项目名称:monodevelop,代码行数:61,代码来源:eval.cs
示例16: 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
示例17: Compatible
public AnonymousExpression Compatible (ResolveContext ec, AnonymousExpression ae)
{
if (block.Resolved)
return this;
// TODO: Implement clone
BlockContext aec = new BlockContext (ec, block, ReturnType);
aec.CurrentAnonymousMethod = ae;
ResolveContext.Options flags = 0;
var am = this as AnonymousMethodBody;
if (ec.HasSet (ResolveContext.Options.InferReturnType) && am != null) {
am.ReturnTypeInference = new TypeInferenceContext ();
}
if (ec.IsInProbingMode)
flags |= ResolveContext.Options.ProbingMode;
if (ec.HasSet (ResolveContext.Options.FieldInitializerScope))
flags |= ResolveContext.Options.FieldInitializerScope;
if (ec.HasSet (ResolveContext.Options.ExpressionTreeConversion))
flags |= ResolveContext.Options.ExpressionTreeConversion;
aec.Set (flags);
var errors = ec.Report.Errors;
bool res = Block.Resolve (ec.CurrentBranching, aec, null);
if (am != null && am.ReturnTypeInference != null) {
am.ReturnTypeInference.FixAllTypes (ec);
ReturnType = am.ReturnTypeInference.InferredTypeArguments [0];
am.ReturnTypeInference = null;
//
// If e is synchronous the inferred return type is T
// If e is asynchronous the inferred return type is Task<T>
//
if (block.IsAsync && ReturnType != null) {
ReturnType = ec.Module.PredefinedTypes.TaskGeneric.TypeSpec.MakeGenericType (ec, new [] { ReturnType });
}
}
if (res && errors != ec.Report.Errors)
return null;
return res ? this : null;
}
开发者ID:nylen,项目名称:SharpDevelop,代码行数:51,代码来源:anonymous.cs
示例18: DoResolve
protected override bool DoResolve(BlockContext ec)
{
iterator = ec.CurrentIterator;
return Yield.CheckContext (ec, loc);
}
开发者ID:speier,项目名称:shake,代码行数:5,代码来源:iterators.cs
示例19: EmitJs
public override void EmitJs (JsEmitContext jec)
{
base.EmitJs (jec);
bool is_static = (this.ModFlags & Modifiers.STATIC) != 0;
if (!is_static) {
jec.Buf.Write ("\tfunction " + this.Parent.MemberName.Name + "(", Location);
parameters.EmitJs (jec);
jec.Buf.Write (") ");
}
BlockContext bc = new BlockContext (this, block, Compiler.BuiltinTypes.Void);
bc.Set (ResolveContext.Options.ConstructorScope);
bool emitted_block = false;
if (block != null) {
//
// If we use a "this (...)" constructor initializer, then
// do not emit field initializers, they are initialized in the other constructor
//
if (!(Initializer is ConstructorThisInitializer))
Parent.PartialContainer.ResolveFieldInitializers (bc);
if (!IsStatic) {
if (Initializer == null) {
if (Parent.PartialContainer.Kind == MemberKind.Struct) {
//
// If this is a non-static `struct' constructor and doesn't have any
// initializer, it must initialize all of the struct's fields.
//
block.AddThisVariable (bc);
} else if (Parent.PartialContainer.Kind == MemberKind.Class) {
Initializer = new GeneratedBaseInitializer (Location);
}
}
if (Initializer != null &&
!(bc.FileType == SourceFileType.PlayScript && Initializer.IsAsExplicitSuperCall)) {
//
// mdb format does not support reqions. Try to workaround this by emitting the
// sequence point at initializer. Any breakpoint at constructor header should
// be adjusted to this sequence point as it's the next one which follows.
//
block.AddScopeStatement (new StatementExpression (Initializer));
}
}
if (block.Resolve (null, bc, this)) {
block.EmitBlockJs (jec, false, is_static);
emitted_block = true;
}
}
if (!is_static) {
if (!emitted_block)
jec.Buf.Write ("{\n\t}", Location);
jec.Buf.Write ("\n");
}
block = null;
}
开发者ID:OpenFlex,项目名称:playscript-mono,代码行数:63,代码来源:method.cs
示例20: ResolveFieldInitializers
public void ResolveFieldInitializers (BlockContext ec)
{
Debug.Assert (!IsPartialPart);
if (ec.IsStatic) {
if (initialized_static_fields == null)
return;
bool has_complex_initializer = !ec.Module.Compiler.Settings.Optimize;
int i;
ExpressionStatement [] init = new ExpressionStatement [initialized_static_fields.Count];
for (i = 0; i < initialized_static_fields.Count; ++i) {
FieldInitializer fi = initialized_static_fields [i];
ExpressionStatement s = fi.ResolveStatement (ec);
if (s == null) {
s = EmptyExpressionStatement.Instance;
} else if (!fi.IsSideEffectFree) {
has_complex_initializer |= true;
}
init [i] = s;
}
for (i = 0; i < initialized_static_fields.Count; ++i) {
FieldInitializer fi = initialized_static_fields [i];
//
// Need special check to not optimize code like this
// static int a = b = 5;
// static int b = 0;
//
if (!has_complex_initializer && fi.IsDefaultInitializer)
continue;
ec.CurrentBlock.AddScopeStatement (new StatementExpression (init [i]));
}
return;
}
if (initialized_fields == null)
return;
for (int i = 0; i < initialized_fields.Count; ++i) {
FieldInitializer fi = initialized_fields [i];
ExpressionStatement s = fi.ResolveStatement (ec);
if (s == null)
continue;
//
// Field is re-initialized to its default value => removed
//
if (fi.IsDefaultInitializer && ec.Module.Compiler.Settings.Optimize)
continue;
ec.CurrentBlock.AddScopeStatement (new StatementExpression (s));
}
}
开发者ID:fvalette,项目名称:mono,代码行数:57,代码来源:class.cs
注:本文中的Mono.CSharp.BlockContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论