本文整理汇总了C#中Mono.CSharp.StatementExpression类的典型用法代码示例。如果您正苦于以下问题:C# StatementExpression类的具体用法?C# StatementExpression怎么用?C# StatementExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StatementExpression类属于Mono.CSharp命名空间,在下文中一共展示了StatementExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: case_769
void case_769()
#line 4888 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
Expression expr = (Expression) yyVals[0+yyTop];
ExpressionStatement s;
s = new OptionalAssign (new SimpleName ("$retval", lexer.Location), expr, lexer.Location);
yyVal = new StatementExpression (s);
}
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:9,代码来源:cs-parser.cs
示例2: Resolve
public override bool Resolve (BlockContext ec)
{
Block variables_block = variable.local_info.Block;
copy = TemporaryVariableReference.Create (for_each.expr.Type, variables_block, loc);
copy.Resolve (ec);
int rank = length_exprs.Length;
Arguments list = new Arguments (rank);
for (int i = 0; i < rank; i++) {
var v = TemporaryVariableReference.Create (TypeManager.int32_type, variables_block, loc);
variables[i] = v;
counter[i] = new StatementExpression (new UnaryMutator (UnaryMutator.Mode.PostIncrement, v, loc));
counter[i].Resolve (ec);
if (rank == 1) {
length_exprs [i] = new MemberAccess (copy, "Length").Resolve (ec);
} else {
lengths[i] = TemporaryVariableReference.Create (TypeManager.int32_type, variables_block, loc);
lengths[i].Resolve (ec);
Arguments args = new Arguments (1);
args.Add (new Argument (new IntConstant (i, loc)));
length_exprs [i] = new Invocation (new MemberAccess (copy, "GetLength"), args).Resolve (ec);
}
list.Add (new Argument (v));
}
access = new ElementAccess (copy, list, loc).Resolve (ec);
if (access == null)
return false;
Expression var_type = for_each.type;
VarExpr ve = var_type as VarExpr;
if (ve != null) {
// Infer implicitly typed local variable from foreach array type
var_type = new TypeExpression (access.Type, ve.Location);
}
var_type = var_type.ResolveAsTypeTerminal (ec, false);
if (var_type == null)
return false;
conv = Convert.ExplicitConversion (ec, access, var_type.Type, loc);
if (conv == null)
return false;
bool ok = true;
ec.StartFlowBranching (FlowBranching.BranchingType.Loop, loc);
ec.CurrentBranching.CreateSibling ();
variable.local_info.Type = conv.Type;
variable.Resolve (ec);
ec.StartFlowBranching (FlowBranching.BranchingType.Embedded, loc);
if (!statement.Resolve (ec))
ok = false;
ec.EndFlowBranching ();
// There's no direct control flow from the end of the embedded statement to the end of the loop
ec.CurrentBranching.CurrentUsageVector.Goto ();
ec.EndFlowBranching ();
return ok;
}
开发者ID:alisci01,项目名称:mono,代码行数:67,代码来源:statement.cs
示例3: Visit
public override object Visit(StatementExpression statementExpression)
{
var result = new ExpressionStatement();
var expr = statementExpression.Expr.Accept(this) as Expression;
if (expr != null)
result.AddChild(expr, Roles.Expression);
var location = LocationsBag.GetLocations(statementExpression);
if (location != null)
result.AddChild(new CSharpTokenNode(Convert(location [0]), Roles.Semicolon), Roles.Semicolon);
return result;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:11,代码来源:CSharpParser.cs
示例4: Visit
public override object Visit (StatementExpression statementExpression)
{
var result = new MonoDevelop.CSharp.Dom.ExpressionStatement ();
result.AddChild ((INode)statementExpression.Expr.Accept (this), MonoDevelop.CSharp.Dom.ExpressionStatement.Roles.Expression);
var location = LocationsBag.GetLocations (statementExpression);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), MonoDevelop.CSharp.Dom.ExpressionStatement.Roles.Semicolon);
return result;
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:9,代码来源:CSharpParser.cs
示例5: case_831
void case_831()
#line 5564 "cs-parser.jay"
{
Expression expr = (Expression) yyVals[0+yyTop];
ExpressionStatement s;
s = new OptionalAssign (new SimpleName ("$retval", lexer.Location), expr, lexer.Location);
yyVal = new StatementExpression (s);
}
开发者ID:segaman,项目名称:NRefactory,代码行数:9,代码来源:cs-parser.cs
示例6: CreateHoistedBaseCallProxy
//
// Creates a proxy base method call inside this container for hoisted base member calls
//
public MethodSpec CreateHoistedBaseCallProxy (ResolveContext rc, MethodSpec method)
{
Method proxy_method;
//
// One proxy per base method is enough
//
if (hoisted_base_call_proxies == null) {
hoisted_base_call_proxies = new Dictionary<MethodSpec, Method> ();
proxy_method = null;
} else {
hoisted_base_call_proxies.TryGetValue (method, out proxy_method);
}
if (proxy_method == null) {
string name = CompilerGeneratedClass.MakeName (method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count);
var base_parameters = new Parameter[method.Parameters.Count];
for (int i = 0; i < base_parameters.Length; ++i) {
var base_param = method.Parameters.FixedParameters[i];
base_parameters[i] = new Parameter (new TypeExpression (method.Parameters.Types[i], Location),
base_param.Name, base_param.ModFlags, null, Location);
base_parameters[i].Resolve (this, i);
}
var cloned_params = ParametersCompiled.CreateFullyResolved (base_parameters, method.Parameters.Types);
if (method.Parameters.HasArglist) {
cloned_params.FixedParameters[0] = new Parameter (null, "__arglist", Parameter.Modifier.NONE, null, Location);
cloned_params.Types[0] = Module.PredefinedTypes.RuntimeArgumentHandle.Resolve (Location);
}
GenericMethod generic_method;
MemberName member_name;
if (method.IsGeneric) {
//
// Copy all base generic method type parameters info
//
var hoisted_tparams = method.GenericDefinition.TypeParameters;
var targs = new TypeArguments ();
var type_params = new TypeParameter[hoisted_tparams.Length];
for (int i = 0; i < type_params.Length; ++i) {
var tp = hoisted_tparams[i];
targs.Add (new TypeParameterName (tp.Name, null, Location));
type_params[i] = new TypeParameter (tp, this, null, new MemberName (tp.Name), null);
}
member_name = new MemberName (name, targs, Location);
generic_method = new GenericMethod (NamespaceEntry, this, member_name, type_params,
new TypeExpression (method.ReturnType, Location), cloned_params);
} else {
member_name = new MemberName (name);
generic_method = null;
}
// Compiler generated proxy
proxy_method = new Method (this, generic_method, new TypeExpression (method.ReturnType, Location),
Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN,
member_name, cloned_params, null);
var block = new ToplevelBlock (Compiler, proxy_method.ParameterInfo, Location);
var mg = MethodGroupExpr.CreatePredefined (method, method.DeclaringType, Location);
mg.InstanceExpression = new BaseThis (method.DeclaringType, Location);
// Get all the method parameters and pass them as arguments
var real_base_call = new Invocation (mg, block.GetAllParametersArguments ());
Statement statement;
if (method.ReturnType == TypeManager.void_type)
statement = new StatementExpression (real_base_call);
else
statement = new Return (real_base_call, Location);
block.AddStatement (statement);
proxy_method.Block = block;
methods.Add (proxy_method);
proxy_method.Define ();
hoisted_base_call_proxies.Add (method, proxy_method);
}
return proxy_method.Spec;
}
开发者ID:famousthom,项目名称:monodevelop,代码行数:85,代码来源:class.cs
示例7: 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
示例8: case_831
void case_831()
#line 5561 "cs-parser.jay"
{
Expression expr = (Expression) yyVals[0+yyTop];
yyVal = new StatementExpression (new OptionalAssign (expr, lexer.Location));
}
开发者ID:lorry-lee,项目名称:vimlorry,代码行数:6,代码来源:cs-parser.cs
示例9: case_779
void case_779()
{
Expression expr = (Expression) yyVals[0+yyTop];
ExpressionStatement s;
s = new OptionalAssign (new SimpleName ("$retval", lexer.Location), expr, lexer.Location);
yyVal = new StatementExpression (s);
}
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:8,代码来源:cs-parser.cs
示例10: case_778
void case_778()
#line 4981 "cs-parser.jay"
{
ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement;
if (s == null) {
Expression.Error_InvalidExpressionStatement (report, GetLocation (yyVals[0+yyTop]));
yyVal = new StatementExpression (EmptyExpressionStatement.Instance);
} else {
yyVal = new StatementExpression (s);
}
}
开发者ID:hduregger,项目名称:monodevelop,代码行数:11,代码来源:cs-parser.cs
示例11: case_778
void case_778()
{
ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement;
if (s == null) {
Expression.Error_InvalidExpressionStatement (report, GetLocation (yyVals[0+yyTop]));
yyVal = new StatementErrorExpression (yyVals[0+yyTop] as Expression);
} else {
yyVal = new StatementExpression (s);
}
}
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:10,代码来源:cs-parser.cs
示例12: yyparse
//.........这里部分代码省略.........
.Select(t =>(Expression)(t.Type != null
? new TypeOf(t.Type,location)
: new TypeOf(t,location))
).ToList();
var initializer = new ArrayInitializer(types,location);
var parameterTypes = new ImplicitlyTypedArrayCreation (
new ComposedTypeSpecifier (1, location),
initializer,
location);
lbag.AddLocation (parameterTypes, location, location);
argumentsForGetMethod.Add(new Argument(parameterTypes));
var getMethodExpression = new Invocation(new MemberAccess(getTypeExpression,"GetMethod"),argumentsForGetMethod);
var argumentsForMethod = new Arguments(2);
var delegatedArguments = parameters.Skip(2).Select(p =>
(Expression)new Cast(
new TypeExpression(compiler.BuiltinTypes.Object,location),
new SimpleName(p.Name,location),
location)).ToList();
argumentsForMethod.Add(new Argument(new SimpleName("self", null, location)));
if(delegatedArguments.Any()){
initializer = new ArrayInitializer(delegatedArguments,location);
argumentsForMethod.Add(new Argument(new ImplicitlyTypedArrayCreation(
new ComposedTypeSpecifier (1, location),
initializer,
location)));
} else {
argumentsForMethod.Add(new Argument(new ArrayCreation(new TypeExpression(compiler.BuiltinTypes.Object,location),new ArrayInitializer(0,location))));
}
var invocation = new Invocation(new MemberAccess(getMethodExpression,"Invoke"),argumentsForMethod);
Statement statement = new StatementExpression(invocation);
var retType = (returnType as TypeExpression);
if(retType != null && retType.Type.Name != "Void"){
var cast = new Cast(returnType,invocation,location);
statement = new Return(cast,location);
}
dummy.Block = new ToplevelBlock (compiler, parametersCompiled, GetLocation(yyVals[-9+yyTop]));
/*var exceptionExpression = new New(new MemberName("InvalidOperationException",GetLocation($1)).GetTypeExpression(),new Arguments(0),GetLocation($1));*/
dummy.Block.AddStatement( statement);
lbag.AddMember(dummy,mod_locations, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop]));
((Class)current_extensionContainer).AddMethod(dummy);
}
}
if (doc_support)
method.DocComment = Lexer.consume_doc_comment ();
lbag.AddMember (method, mod_locations, GetLocation (yyVals[-5+yyTop]), GetLocation (yyVals[-2+yyTop]));
yyVal = method;
}
break;
case 176:
#line 1666 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
lexer.parsing_generic_declaration = true;
}
break;
case 177:
#line 1671 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
lexer.parsing_generic_declaration = false;
valid_param_mod = ParameterModifierType.All;
}
开发者ID:runefs,项目名称:Marvin,代码行数:67,代码来源:cs-parser.cs
示例13: case_827
void case_827()
#line 5524 "cs-parser.jay"
{
ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement;
if (s == null) {
var expr = yyVals[0+yyTop] as Expression;
expr.Error_InvalidExpressionStatement (report);
yyVal = new StatementErrorExpression (expr);
} else {
yyVal = new StatementExpression (s);
}
}
开发者ID:artifexor,项目名称:NRefactory,代码行数:12,代码来源:cs-parser.cs
示例14: CreateDisposeCall
protected override Statement CreateDisposeCall (BlockContext bc, LocalVariable lv)
{
if (TypeManager.void_dispose_void == null) {
TypeManager.void_dispose_void = TypeManager.GetPredefinedMethod (
TypeManager.idisposable_type, "Dispose", loc, TypeSpec.EmptyTypes);
}
//
// Fabricates code like
//
// if ((temp = vr as IDisposable) != null) temp.Dispose ();
//
var dispose_variable = LocalVariable.CreateCompilerGenerated (TypeManager.idisposable_type, bc.CurrentBlock, loc);
var idisaposable_test = new Binary (Binary.Operator.Inequality, new CompilerAssign (
dispose_variable.CreateReferenceExpression (bc, loc),
new As (lv.CreateReferenceExpression (bc, loc), new TypeExpression (dispose_variable.Type, loc), loc),
loc), new NullLiteral (loc), loc);
var dispose_mg = MethodGroupExpr.CreatePredefined (TypeManager.void_dispose_void, TypeManager.idisposable_type, loc);
dispose_mg.InstanceExpression = dispose_variable.CreateReferenceExpression (bc, loc);
Statement dispose = new StatementExpression (new Invocation (dispose_mg, null));
return new If (idisaposable_test, dispose, loc);
}
开发者ID:alisci01,项目名称:mono,代码行数:26,代码来源:statement.cs
示例15: CreateExpressionTree
public Expression CreateExpressionTree (EmitContext ec, Location loc)
{
ArrayList initializers = new ArrayList (Count);
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));
if (se.Resolve (ec))
ec.CurrentBlock.AddScopeStatement (se);
initializers.Add (p.ExpressionTreeVariableReference ());
}
return new ArrayCreation (
Parameter.ResolveParameterExpressionType (ec, loc),
"[]", initializers, loc);
}
开发者ID:lewurm,项目名称:benchmarker,代码行数:19,代码来源:parameter.cs
示例16: Visit
public virtual object Visit (StatementExpression statementExpression)
{
return null;
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:visit.cs
示例17: case_768
void case_768()
#line 4895 "cs-parser.jay"
{
ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement;
if (s == null) {
Expression.Error_InvalidExpressionStatement (Report, GetLocation (yyVals[0+yyTop]));
s = EmptyExpressionStatement.Instance;
}
yyVal = new StatementExpression (s);
}
开发者ID:Ein,项目名称:monodevelop,代码行数:11,代码来源:cs-parser.cs
示例18: case_830
void case_830()
#line 5551 "cs-parser.jay"
{
ExpressionStatement s = yyVals[0+yyTop] as ExpressionStatement;
if (s == null) {
var expr = yyVals[0+yyTop] as Expression;
yyVal = new StatementErrorExpression (expr);
} else {
yyVal = new StatementExpression (s);
}
}
开发者ID:segaman,项目名称:NRefactory,代码行数:11,代码来源:cs-parser.cs
示例19: ResolveIncrement
public void ResolveIncrement (BlockContext ec)
{
increment = new StatementExpression (new UnaryMutator (UnaryMutator.Mode.PostIncrement, this, loc));
increment.Resolve (ec);
}
开发者ID:tgiphil,项目名称:mono,代码行数:5,代码来源:statement.cs
示例20: 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
注:本文中的Mono.CSharp.StatementExpression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论