本文整理汇总了C#中MethodDeclaration.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# MethodDeclaration.Clone方法的具体用法?C# MethodDeclaration.Clone怎么用?C# MethodDeclaration.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MethodDeclaration
的用法示例。
在下文中一共展示了MethodDeclaration.Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitCXXMethodDecl
public override void VisitCXXMethodDecl(CXXMethodDecl decl, VisitKind visitKind)
{
if (!MethodIsBindable (decl, visitKind))
return;
var cmethodBuilder = new StringBuilder();
AstType pinvokeReturn, methodReturn;
WrapKind returnIsWrapped;
ICSharpCode.NRefactory.CSharp.ParameterModifier pinvokeMod, methodMod;
LookupMarshalTypes(decl.ReturnQualType, out pinvokeReturn, out pinvokeMod, out methodReturn, out methodMod, out returnIsWrapped, isReturn: true);
var methodReturn2 = methodReturn.Clone();
var propertyInfo = ScanBaseTypes.GetPropertyInfo(decl);
if (propertyInfo != null) {
propertyInfo.HostType = currentType;
if (decl.Name.StartsWith("Get") || decl.Name.StartsWith("Is"))
propertyInfo.MethodReturn = methodReturn.Clone();
}
var methodName = decl.Name;
if (currentTypeNames.Contains(methodName))
methodName += (uniqueMethodName++).ToString();
currentTypeNames.Add(methodName);
//
// PInvoke declaration + C counterpart declaration
//
string pinvoke_name = currentType.Name + "_" + methodName;
var isConstructor = decl is CXXConstructorDecl;
if (isConstructor) {
pinvokeReturn = new SimpleType ("IntPtr");
// Do not bind a default constructor for Skeleton
if (currentType.Name == "Skeleton")
return;
}
var pinvoke = new MethodDeclaration
{
Name = pinvoke_name,
ReturnType = pinvokeReturn,
Modifiers = Modifiers.Extern | Modifiers.Static | Modifiers.Internal
};
if (!decl.IsStatic && !isConstructor)
pinvoke.Parameters.Add(new ParameterDeclaration(new SimpleType("IntPtr"), "handle"));
var dllImport = new Attribute { Type = new SimpleType("DllImport") };
dllImport.Arguments.Add (new PrimitiveExpression ("mono-urho"));
dllImport.Arguments.Add (new AssignmentExpression (new IdentifierExpression ("CallingConvention"), csParser.ParseExpression ("CallingConvention.Cdecl")));
pinvoke.Attributes.Add(new AttributeSection(dllImport));
// The C counterpart
var cinvoke = new StringBuilder();
string marshalReturn = "{0}";
string creturnType = CleanTypeCplusplus(decl.ReturnQualType);
switch (creturnType) {
case "bool":
creturnType = "int";
break;
case "Urho3D::StringHash":
creturnType = "int";
marshalReturn = "({0}).Value ()";
break;
case "Urho3D::String":
case "const Urho3D::String &":
case "const class Urho3D::String &":
creturnType = "const char *";
marshalReturn = "strdup(({0}).CString ())";
break;
case "const struct Urho3D::TileMapInfo2D &":
creturnType = "Urho3D::TileMapInfo2D";
break;
case "const struct Urho3D::CrowdObstacleAvoidanceParams &":
creturnType = "Urho3D::CrowdObstacleAvoidanceParams";
break;
case "const class Urho3D::Vector3 &":
case "const class Urho3D::Vector2 &":
case "const class Urho3D::Vector4 &":
case "const class Urho3D::IntVector2 &":
case "const class Urho3D::Quaternion &":
case "const class Urho3D::Plane &":
case "const class Urho3D::BoundingBox &":
case "const class Urho3D::Color &":
case "Urho3D::Vector3":
case "Urho3D::Vector2":
case "Urho3D::Vector4":
case "Urho3D::IntVector2":
case "Urho3D::Quaternion":
case "Urho3D::Plane":
case "Urho3D::BoundingBox":
case "Urho3D::Color":
var nsIndex = creturnType.IndexOf ("Urho3D::") + "Urho3D".Length;
creturnType = "Interop" + creturnType.Remove (0, nsIndex).Trim ('&', ' ') + " ";
marshalReturn = "*((" + creturnType + " *) &({0}))";
break;
//.........这里部分代码省略.........
示例2: VisitMethodDeclaration
public override void VisitMethodDeclaration (MethodDeclaration methodDeclaration)
{
base.VisitMethodDeclaration (methodDeclaration);
//
// Try to force the method into a form we can handle
//
var m = methodDeclaration;
var gotos = m.Body.Descendants.OfType<GotoStatement> ().ToList ();
if (gotos.Count == 0)
return;
if (HasBadLabels (m)) {
foreach (var ts in transforms) {
m = (MethodDeclaration)methodDeclaration.Clone ();
m.AcceptVisitor (new LabelLoops ());
m.AcceptVisitor (new SwitchSectionBlocksToStatements ());
foreach (var t in ts) {
m.AcceptVisitor (t);
m.AcceptVisitor (new RemoveRedundantGotos ());
m.AcceptVisitor (new RemoveUnreachableStatements ());
}
m.AcceptVisitor (new RemoveLabelsWithoutGotos ());
if (!HasBadLabels (m)) {
break;
}
}
if (HasBadLabels (m)) {
App.Warning ("! GOTO labels at different levels in {0}.{1}(). This is not supported.",
methodDeclaration.GetParent<TypeDeclaration> ().Name,
methodDeclaration.Name);
return;
} else {
methodDeclaration.ReplaceWith (m);
}
}
//
// Handle it
//
m.AcceptVisitor (new CreateGotoLoop ());
m.AcceptVisitor (new RewriteGotos ());
}