本文整理汇总了C#中Mono.CSharp.Return类的典型用法代码示例。如果您正苦于以下问题:C# Return类的具体用法?C# Return怎么用?C# Return使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Return类属于Mono.CSharp命名空间,在下文中一共展示了Return类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: 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 = CompilerGeneratedContainer.MakeName (method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count);
MemberName member_name;
TypeArguments targs = null;
TypeSpec return_type = method.ReturnType;
var local_param_types = method.Parameters.Types;
if (method.IsGeneric) {
//
// Copy all base generic method type parameters info
//
var hoisted_tparams = method.GenericDefinition.TypeParameters;
var tparams = new TypeParameters ();
targs = new TypeArguments ();
targs.Arguments = new TypeSpec[hoisted_tparams.Length];
for (int i = 0; i < hoisted_tparams.Length; ++i) {
var tp = hoisted_tparams[i];
var local_tp = new TypeParameter (tp, null, new MemberName (tp.Name, Location), null);
tparams.Add (local_tp);
targs.Add (new SimpleName (tp.Name, Location));
targs.Arguments[i] = local_tp.Type;
}
member_name = new MemberName (name, tparams, Location);
//
// Mutate any method type parameters from original
// to newly created hoisted version
//
var mutator = new TypeParameterMutator (hoisted_tparams, tparams);
return_type = mutator.Mutate (return_type);
local_param_types = mutator.Mutate (local_param_types);
} else {
member_name = new MemberName (name);
}
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 (local_param_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 ();
}
// Compiler generated proxy
proxy_method = new Method (this, new TypeExpression (return_type, Location),
Modifiers.PRIVATE | Modifiers.COMPILER_GENERATED | Modifiers.DEBUGGER_HIDDEN,
member_name, cloned_params, null);
var block = new ToplevelBlock (Compiler, proxy_method.ParameterInfo, Location) {
IsCompilerGenerated = true
};
var mg = MethodGroupExpr.CreatePredefined (method, method.DeclaringType, Location);
mg.InstanceExpression = new BaseThis (method.DeclaringType, Location);
if (targs != null)
mg.SetTypeArguments (rc, targs);
// Get all the method parameters and pass them as arguments
var real_base_call = new Invocation (mg, block.GetAllParametersArguments ());
Statement statement;
if (method.ReturnType.Kind == MemberKind.Void)
statement = new StatementExpression (real_base_call);
else
statement = new Return (real_base_call, Location);
block.AddStatement (statement);
proxy_method.Block = block;
members.Add (proxy_method);
proxy_method.Define ();
proxy_method.PrepareEmit ();
hoisted_base_call_proxies.Add (method, proxy_method);
//.........这里部分代码省略.........
开发者ID:fvalette,项目名称:mono,代码行数:101,代码来源:class.cs
示例2: 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
示例3: Visit
public override object Visit (Return returnStatement)
{
var result = new ReturnStatement ();
result.AddChild (new CSharpTokenNode (Convert (returnStatement.loc), "return".Length), ReturnStatement.Roles.Keyword);
if (returnStatement.Expr != null)
result.AddChild ((INode)returnStatement.Expr.Accept (this), ReturnStatement.Roles.Expression);
var location = LocationsBag.GetLocations (returnStatement);
if (location != null)
result.AddChild (new CSharpTokenNode (Convert (location[0]), 1), ReturnStatement.Roles.Semicolon);
return result;
}
开发者ID:pgoron,项目名称:monodevelop,代码行数:14,代码来源:CSharpParser.cs
示例4: case_903
void case_903()
#line 6003 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
yyVal = new Return (null, GetLocation (yyVals[-1+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:6,代码来源:cs-parser.cs
示例5: 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
示例6: case_901
void case_901()
#line 5993 "cs-parser.jay"
{
yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:6,代码来源:cs-parser.cs
示例7: case_902
void case_902()
#line 5998 "cs-parser.jay"
{
Error_SyntaxError (yyToken);
yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
}
开发者ID:segaman,项目名称:NRefactory,代码行数:6,代码来源:cs-parser.cs
示例8: Visit
public virtual object Visit (Return returnStatement)
{
return null;
}
开发者ID:KAW0,项目名称:Alter-Native,代码行数:4,代码来源:visit.cs
示例9: CreateAutomaticProperty
void CreateAutomaticProperty ()
{
// Create backing field
Field field = new BackingField (this);
if (!field.Define ())
return;
Parent.PartialContainer.AddField (field);
FieldExpr fe = new FieldExpr (field, Location);
if ((field.ModFlags & Modifiers.STATIC) == 0)
fe.InstanceExpression = new CompilerGeneratedThis (fe.Type, Location);
// Create get block
Get.Block = new ToplevelBlock (Compiler, ParametersCompiled.EmptyReadOnlyParameters, Location);
Return r = new Return (fe, Location);
Get.Block.AddStatement (r);
// Create set block
Set.Block = new ToplevelBlock (Compiler, Set.ParameterInfo, Location);
Assign a = new SimpleAssign (fe, new SimpleName ("value", Location));
Set.Block.AddStatement (new StatementExpression (a));
}
开发者ID:afaerber,项目名称:mono,代码行数:23,代码来源:property.cs
示例10: yyparse
//.........这里部分代码省略.........
var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
yyVal = new Parameter ((FullNamedExpression) yyVals[-1+yyTop], lt.Value, Parameter.Modifier.NONE, null, lt.Location);
}
break;
case 612:
#line 4106 "cs-parser.jay"
{
var lt = (Tokenizer.LocatedToken) yyVals[0+yyTop];
yyVal = new ImplicitLambdaParameter (lt.Value, lt.Location);
}
break;
case 613:
#line 4113 "cs-parser.jay"
{ yyVal = ParametersCompiled.EmptyReadOnlyParameters; }
break;
case 614:
#line 4114 "cs-parser.jay"
{
var pars_list = (List<Parameter>) yyVals[0+yyTop];
yyVal = new ParametersCompiled (compiler, pars_list.ToArray ());
}
break;
case 615:
#line 4121 "cs-parser.jay"
{
start_block (lexer.Location);
}
break;
case 616:
#line 4125 "cs-parser.jay"
{
Block b = end_block (lexer.Location);
b.AddStatement (new ContextualReturn ((Expression) yyVals[0+yyTop]));
yyVal = b;
}
break;
case 617:
#line 4130 "cs-parser.jay"
{
yyVal = yyVals[0+yyTop];
}
break;
case 618:
#line 4137 "cs-parser.jay"
{
var lt = (Tokenizer.LocatedToken) yyVals[-1+yyTop];
Parameter p = new ImplicitLambdaParameter (lt.Value, lt.Location);
start_anonymous (true, new ParametersCompiled (compiler, p), GetLocation (yyVals[-1+yyTop]));
}
break;
case 619:
#line 4143 "cs-parser.jay"
{
yyVal = end_anonymous ((ToplevelBlock) yyVals[0+yyTop]);
}
break;
case 620:
#line 4147 "cs-parser.jay"
{
if (RootContext.Version <= LanguageVersion.ISO_2)
Report.FeatureIsNotAvailable (GetLocation (yyVals[0+yyTop]), "lambda expressions");
valid_param_mod = ParameterModifierType.Ref | ParameterModifierType.Out;
}
break;
开发者ID:speier,项目名称:shake,代码行数:67,代码来源:cs-parser.cs
示例11: 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
示例12: case_852
void case_852()
{
Error_SyntaxError (yyToken);
yyVal = new Return (null, GetLocation (yyVals[-1+yyTop]));
}
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:5,代码来源:cs-parser.cs
示例13: case_851
void case_851()
{
Error_SyntaxError (yyToken);
yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
}
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:5,代码来源:cs-parser.cs
示例14: case_850
void case_850()
{
yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop]));
}
开发者ID:animaonline,项目名称:Portable-Mono.CSharp,代码行数:5,代码来源:cs-parser.cs
示例15: yyparse
//.........这里部分代码省略.........
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;
}
break;
case 178:
#line 1676 "D:\GitHub\M\Marvin\mcs\cs-parser.jay"
{
开发者ID:runefs,项目名称:Marvin,代码行数:67,代码来源:cs-parser.cs
示例16: case_824
void case_824()
#line 5204 "C:\Projects\Junk\mono\mcs\class\Mono.CSharp\..\..\mcs\cs-parser.jay"
{
yyVal = new Return ((Expression) yyVals[-1+yyTop], GetLocation (yyVals[-2+yyTop]));
lbag.AddStatement (yyVal, GetLocation (yyVals[0+yyTop]));
}
开发者ID:RainsSoft,项目名称:MonoCompilerAsAService,代码行数:6,代码来源:cs-parser.cs
注:本文中的Mono.CSharp.Return类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论