本文整理汇总了C#中Mono.CSharp.ParametersBlock.AddStatement方法的典型用法代码示例。如果您正苦于以下问题:C# ParametersBlock.AddStatement方法的具体用法?C# ParametersBlock.AddStatement怎么用?C# ParametersBlock.AddStatement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.ParametersBlock
的用法示例。
在下文中一共展示了ParametersBlock.AddStatement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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(
//.........这里部分代码省略.........