本文整理汇总了C#中Mono.CSharp.AnonymousMethodExpression类的典型用法代码示例。如果您正苦于以下问题:C# AnonymousMethodExpression类的具体用法?C# AnonymousMethodExpression怎么用?C# AnonymousMethodExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnonymousMethodExpression类属于Mono.CSharp命名空间,在下文中一共展示了AnonymousMethodExpression类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: end_anonymous
/*
* Completes the anonymous method processing, if lambda_expr is null, this
* means that we have a Statement instead of an Expression embedded
*/
AnonymousMethodExpression end_anonymous (ParametersBlock anon_block)
{
AnonymousMethodExpression retval;
if (async_block)
anon_block.IsAsync = true;
current_anonymous_method.Block = anon_block;
retval = current_anonymous_method;
async_block = (bool) oob_stack.Pop ();
current_variable = (BlockVariable) oob_stack.Pop ();
current_local_parameters = (ParametersCompiled) oob_stack.Pop ();
current_anonymous_method = (AnonymousMethodExpression) oob_stack.Pop ();
return retval;
}
开发者ID:segaman,项目名称:NRefactory,代码行数:21,代码来源:cs-parser.cs
示例2: Visit
public override object Visit(Mono.CSharp.AnonymousMethodExpression anonymousMethodExpression)
{
var result = new AnonymousMethodExpression();
var location = LocationsBag.GetLocations(anonymousMethodExpression);
int l = 0;
if (anonymousMethodExpression.IsAsync) {
result.IsAsync = true;
result.AddChild(new CSharpTokenNode(Convert(location [l++]), AnonymousMethodExpression.AsyncModifierRole), AnonymousMethodExpression.AsyncModifierRole);
}
if (location != null) {
result.AddChild(new CSharpTokenNode(Convert(location [l++]), AnonymousMethodExpression.DelegateKeywordRole), AnonymousMethodExpression.DelegateKeywordRole);
if (location.Count > l) {
result.HasParameterList = true;
result.AddChild(new CSharpTokenNode(Convert(location [l++]), Roles.LPar), Roles.LPar);
AddParameter(result, anonymousMethodExpression.Parameters);
result.AddChild(new CSharpTokenNode(Convert(location [l++]), Roles.RPar), Roles.RPar);
}
}
if (anonymousMethodExpression.Block != null)
result.AddChild((BlockStatement)anonymousMethodExpression.Block.Accept(this), Roles.Body);
return result;
}
开发者ID:0xb1dd1e,项目名称:NRefactory,代码行数:23,代码来源:CSharpParser.cs
示例3: Visit
public override object Visit (Mono.CSharp.AnonymousMethodExpression anonymousMethodExpression)
{
var result = new AnonymousMethodExpression ();
var location = LocationsBag.GetLocations (anonymousMethodExpression);
if (location != null) {
result.AddChild (new CSharpTokenNode (Convert (location[0]), "delegate".Length), AnonymousMethodExpression.Roles.Keyword);
if (location.Count > 1) {
result.HasParameterList = true;
result.AddChild (new CSharpTokenNode (Convert (location[1]), 1), AnonymousMethodExpression.Roles.LPar);
AddParameter (result, anonymousMethodExpression.Parameters);
result.AddChild (new CSharpTokenNode (Convert (location[2]), 1), AnonymousMethodExpression.Roles.RPar);
}
}
result.AddChild ((BlockStatement)anonymousMethodExpression.Block.Accept (this), AnonymousMethodExpression.Roles.Body);
return result;
}
开发者ID:severinh,项目名称:monodevelop-vala-afrodite-update,代码行数:17,代码来源:CSharpParser.cs
示例4: start_anonymous
void start_anonymous (bool isLambda, ParametersCompiled parameters, bool isAsync, Location loc)
{
oob_stack.Push (current_anonymous_method);
oob_stack.Push (current_local_parameters);
oob_stack.Push (current_variable);
oob_stack.Push (async_block);
current_local_parameters = parameters;
if (isLambda) {
if (lang_version <= LanguageVersion.ISO_2)
FeatureIsNotAvailable (loc, "lambda expressions");
current_anonymous_method = new LambdaExpression (loc);
} else {
if (lang_version == LanguageVersion.ISO_1)
FeatureIsNotAvailable (loc, "anonymous methods");
current_anonymous_method = new AnonymousMethodExpression (loc);
}
current_anonymous_method.IsAsync = isAsync;
async_block = isAsync;
// Force the next block to be created as a ToplevelBlock
parsing_anonymous_method = true;
}
开发者ID:segaman,项目名称:NRefactory,代码行数:25,代码来源:cs-parser.cs
示例5: Visit
public virtual object Visit (AnonymousMethodExpression anonymousMethodExpression)
{
return null;
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:visit.cs
示例6: end_anonymous
/*
* Completes the anonymous method processing, if lambda_expr is null, this
* means that we have a Statement instead of an Expression embedded
*/
AnonymousMethodExpression end_anonymous (ParametersBlock anon_block)
{
AnonymousMethodExpression retval;
current_anonymous_method.Block = anon_block;
retval = current_anonymous_method;
current_variable = (BlockVariableDeclaration) oob_stack.Pop ();
current_local_parameters = (ParametersCompiled) oob_stack.Pop ();
current_anonymous_method = (AnonymousMethodExpression) oob_stack.Pop ();
return retval;
}
开发者ID:Ein,项目名称:monodevelop,代码行数:17,代码来源:cs-parser.cs
示例7: start_anonymous
void start_anonymous (bool lambda, ParametersCompiled parameters, Location loc)
{
if (RootContext.Version == LanguageVersion.ISO_1){
Report.FeatureIsNotAvailable (loc, "anonymous methods");
}
oob_stack.Push (current_anonymous_method);
oob_stack.Push (current_local_parameters);
oob_stack.Push (current_variable);
current_local_parameters = parameters;
current_anonymous_method = lambda
? new LambdaExpression (loc)
: new AnonymousMethodExpression (loc);
// Force the next block to be created as a ToplevelBlock
parsing_anonymous_method = true;
}
开发者ID:Ein,项目名称:monodevelop,代码行数:19,代码来源:cs-parser.cs
示例8: AsLocalFunction
public AsLocalFunction (Location loc, string name, AnonymousMethodExpression methodExpr, BlockVariableDeclaration varDecl)
{
this.loc = loc;
this.Name = name;
this.MethodExpr = methodExpr;
this.VarDecl = varDecl;
}
开发者ID:johnv315,项目名称:playscript-mono,代码行数:7,代码来源:ps-lang.cs
示例9: DoImplicitConversionStandard
static Expression DoImplicitConversionStandard (ResolveContext ec, Expression expr, TypeSpec target_type, Location loc, bool explicit_cast, bool upconvert_only)
{
if (expr.eclass == ExprClass.MethodGroup){
if (!target_type.IsDelegate){
if (ec.FileType == SourceFileType.PlayScript &&
(target_type == ec.BuiltinTypes.Dynamic || target_type == ec.BuiltinTypes.Delegate)) {
MethodGroupExpr mg = expr as MethodGroupExpr;
if (mg != null) {
if (mg.Candidates.Count != 1) {
ec.Report.Error (7021, loc, "Ambiguous overloaded methods `{0}' when assigning to Function or Object type", mg.Name);
return null;
}
var ms = (MethodSpec)mg.Candidates[0];
var del_type = Delegate.CreateDelegateTypeFromMethodSpec(ec, ms, loc);
// If return is "Delegate", we create a var args anonymous method which calls the target method..
if (del_type == ec.BuiltinTypes.Delegate) {
var objArrayType = new ComposedCast (
new TypeExpression(ec.BuiltinTypes.Object, loc),
ComposedTypeSpecifier.CreateArrayDimension (1, loc));
var parameters = new ParametersCompiled(new Parameter[] {
new ParamsParameter(objArrayType, "args", null, loc) }, false);
var dynCall = new AnonymousMethodExpression(expr.Location, parameters, new TypeExpression(ms.ReturnType, loc));
var block = new ParametersBlock (ec.CurrentBlock, parameters, expr.Location);
dynCall.Block = block;
var args = new Arguments (3);
args.Add (new Argument(new TypeOf(new TypeExpression(ms.DeclaringType, loc), loc)));
args.Add (new Argument(new StringLiteral(ec.BuiltinTypes, ms.Name, loc)));
args.Add (new Argument(new SimpleName("args", loc)));
var call = new Invocation (new MemberAccess(new MemberAccess(new SimpleName("PlayScript", loc), "Support", loc), "VarArgCall", loc), args);
if (ms.ReturnType == ec.BuiltinTypes.Void) {
block.AddStatement (new StatementExpression(call));
} else {
block.AddStatement (new Return(call, loc));
}
return dynCall.Resolve (ec);
} else {
// Otherwise cast to the specific delegate type
return new ImplicitDelegateCreation (del_type, mg, loc).Resolve (ec);
}
}
}
return null;
}
//
// Only allow anonymous method conversions on post ISO_1
//
if (ec.Module.Compiler.Settings.Version != LanguageVersion.ISO_1){
MethodGroupExpr mg = expr as MethodGroupExpr;
if (mg != null)
return new ImplicitDelegateCreation (target_type, mg, loc).Resolve (ec);
}
}
TypeSpec expr_type = expr.Type;
Expression e;
if (expr_type == target_type) {
if (expr_type != InternalType.NullLiteral && expr_type != InternalType.AnonymousMethod)
return expr;
return null;
}
// Auto convert types to type objects..
if (ec.FileType == SourceFileType.PlayScript && target_type.BuiltinType == BuiltinTypeSpec.Type.Type && expr is FullNamedExpression) {
FullNamedExpression type_expr = (FullNamedExpression)expr;
if (expr_type != null) {
if (expr_type.MemberDefinition.Namespace == PsConsts.PsRootNamespace) {
switch (expr_type.Name) {
case "String":
type_expr = new TypeExpression (ec.BuiltinTypes.String, type_expr.Location);
break;
case "Number":
type_expr = new TypeExpression (ec.BuiltinTypes.Double, type_expr.Location);
break;
case "Boolean":
type_expr = new TypeExpression (ec.BuiltinTypes.Double, type_expr.Location);
break;
}
} else if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
type_expr = new TypeExpression (ec.Module.PredefinedTypes.AsObject.Resolve(), type_expr.Location);
}
}
return new TypeOf (type_expr, expr.Location).Resolve (ec);
}
if (expr_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
// Implicitly cast references to bools in PlayScript
if (ec.FileType == SourceFileType.PlayScript &&
target_type.BuiltinType == BuiltinTypeSpec.Type.Bool &&
ec.Target != Target.JavaScript) {
var cast_args = new Arguments(1);
cast_args.Add (new Argument(EmptyCast.Create(expr, ec.BuiltinTypes.Object)));
// ec.Report.Warning (7164, 1, expr.Location, "Expensive reference conversion to bool");
return new Invocation(new MemberAccess(new MemberAccess(new SimpleName(
//.........这里部分代码省略.........
开发者ID:johnv315,项目名称:playscript-mono,代码行数:101,代码来源:convert.cs
注:本文中的Mono.CSharp.AnonymousMethodExpression类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论