本文整理汇总了C#中ILCompiler.Compiler.CppCodeGen.CppGenerationBuffer.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CppGenerationBuffer.ToString方法的具体用法?C# CppGenerationBuffer.ToString怎么用?C# CppGenerationBuffer.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILCompiler.Compiler.CppCodeGen.CppGenerationBuffer
的用法示例。
在下文中一共展示了CppGenerationBuffer.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OutputNodes
/// <summary>
/// Output C++ code via a given dependency graph
/// </summary>
/// <param name="nodes">A set of dependency nodes</param>
/// <param name="entrypoint">Code entrypoint</param>
/// <param name="factory">Associated NodeFactory instance</param>
private void OutputNodes(IEnumerable<DependencyNode> nodes, NodeFactory factory)
{
CppGenerationBuffer forwardDefinitions = new CppGenerationBuffer();
CppGenerationBuffer typeDefinitions = new CppGenerationBuffer();
CppGenerationBuffer methodTables = new CppGenerationBuffer();
CppGenerationBuffer optionalFields = new CppGenerationBuffer();
DependencyNodeIterator nodeIterator = new DependencyNodeIterator(nodes, factory);
// Output well-known types to avoid build errors
if (_wellKnownTypeNodes != null)
{
foreach (var wellKnownTypeNode in _wellKnownTypeNodes)
{
OutputTypeNode(wellKnownTypeNode, factory, forwardDefinitions, typeDefinitions, methodTables);
}
}
// Iterate through nodes
foreach (var node in nodeIterator.GetNodes())
{
if (node is EETypeNode && !_emittedTypes.Contains(((EETypeNode)node).Type))
OutputTypeNode(node as EETypeNode, factory, forwardDefinitions, typeDefinitions, methodTables);
else if (node is EETypeOptionalFieldsNode)
optionalFields.Append(GetCodeForObjectNode(node as EETypeOptionalFieldsNode, factory));
}
Out.Write(forwardDefinitions.ToString());
Out.Write(typeDefinitions.ToString());
Out.Write(methodTables.ToString());
Out.Write(optionalFields.ToString());
}
示例2: GetCodeForNodeData
private String GetCodeForNodeData(List<NodeDataSection> nodeDataSections, Relocation[] relocs, byte[] byteData, DependencyNode node, int offset, NodeFactory factory)
{
CppGenerationBuffer nodeDataDecl = new CppGenerationBuffer();
int relocCounter = 0;
int divisionStartIndex = offset;
nodeDataDecl.Indent();
nodeDataDecl.Indent();
nodeDataDecl.AppendLine();
for (int i = 0; i < nodeDataSections.Count; i++)
{
if (nodeDataSections[i].SectionType == NodeDataSectionType.Relocation)
{
Relocation reloc = relocs[relocCounter];
nodeDataDecl.Append(GetCodeForReloc(reloc, node, factory));
nodeDataDecl.Append(",");
relocCounter++;
}
else
{
AppendFormattedByteArray(nodeDataDecl, byteData, divisionStartIndex, divisionStartIndex + nodeDataSections[i].SectionSize);
nodeDataDecl.Append(",");
}
divisionStartIndex += nodeDataSections[i].SectionSize;
nodeDataDecl.AppendLine();
}
return nodeDataDecl.ToString();
}
示例3: GetCodeForNodeStruct
private String GetCodeForNodeStruct(List<NodeDataSection> nodeDataDivs, DependencyNode node)
{
CppGenerationBuffer nodeStructDecl = new CppGenerationBuffer();
int relocCounter = 1;
int i = 0;
nodeStructDecl.Indent();
for (i = 0; i < nodeDataDivs.Count; i++)
{
NodeDataSection section = nodeDataDivs[i];
if (section.SectionType == NodeDataSectionType.Relocation)
{
nodeStructDecl.Append("void* reloc");
nodeStructDecl.Append(relocCounter);
nodeStructDecl.Append(";");
relocCounter++;
}
else
{
nodeStructDecl.Append("unsigned char data");
nodeStructDecl.Append((i + 1) - relocCounter);
nodeStructDecl.Append("[");
nodeStructDecl.Append(section.SectionSize);
nodeStructDecl.Append("];");
}
nodeStructDecl.AppendLine();
}
nodeStructDecl.Exdent();
return nodeStructDecl.ToString();
}
示例4: CompileMethod
public void CompileMethod(CppMethodCodeNode methodCodeNodeNeedingCode)
{
MethodDesc method = methodCodeNodeNeedingCode.Method;
_compilation.Logger.Writer.WriteLine("Compiling " + method.ToString());
if (method.HasCustomAttribute("System.Runtime", "RuntimeImportAttribute"))
{
CompileExternMethod(methodCodeNodeNeedingCode, ((EcmaMethod)method).GetRuntimeImportName());
return;
}
if (method.IsRawPInvoke())
{
CompileExternMethod(methodCodeNodeNeedingCode, method.GetPInvokeMethodMetadata().Name ?? method.Name);
return;
}
var methodIL = _compilation.GetMethodIL(method);
if (methodIL == null)
return;
// TODO: Remove this code once CppCodegen is able to generate code for the reflection startup path.
// The startup path runs before any user code is executed.
// For now we replace the startup path with a simple "ret". Reflection won't work, but
// programs not using reflection will.
if (method.Name == ".cctor")
{
MetadataType owningType = method.OwningType as MetadataType;
if (owningType != null &&
owningType.Name == "ReflectionExecution" && owningType.Namespace == "Internal.Reflection.Execution")
{
methodIL = new Internal.IL.Stubs.ILStubMethodIL(method, new byte[] { (byte)ILOpcode.ret }, Array.Empty<LocalVariableDefinition>(), null);
}
}
try
{
// TODO: hacky special-case
if (method.Name == "_ecvt_s")
throw new NotImplementedException();
var ilImporter = new ILImporter(_compilation, this, method, methodIL);
CompilerTypeSystemContext typeSystemContext = _compilation.TypeSystemContext;
MethodDebugInformation debugInfo = _compilation.GetDebugInfo(methodIL);
if (!_compilation.Options.HasOption(CppCodegenConfigProvider.NoLineNumbersString))
{
IEnumerable<ILSequencePoint> sequencePoints = debugInfo.GetSequencePoints();
if (sequencePoints != null)
ilImporter.SetSequencePoints(sequencePoints);
}
IEnumerable<ILLocalVariable> localVariables = debugInfo.GetLocalVariables();
if (localVariables != null)
ilImporter.SetLocalVariables(localVariables);
IEnumerable<string> parameters = GetParameterNamesForMethod(method);
if (parameters != null)
ilImporter.SetParameterNames(parameters);
ilImporter.Compile(methodCodeNodeNeedingCode);
}
catch (Exception e)
{
_compilation.Logger.Writer.WriteLine(e.Message + " (" + method + ")");
var sb = new CppGenerationBuffer();
sb.AppendLine();
AppendCppMethodDeclaration(sb, method, true);
sb.AppendLine();
sb.Append("{");
sb.Indent();
sb.AppendLine();
sb.Append("throw 0xC000C000;");
sb.Exdent();
sb.AppendLine();
sb.Append("}");
methodCodeNodeNeedingCode.SetCode(sb.ToString(), Array.Empty<Object>());
}
}
示例5: GetCodeForVirtualMethod
private String GetCodeForVirtualMethod(MethodDesc method, int slot)
{
var sb = new CppGenerationBuffer();
sb.Indent();
if (method.OwningType.IsInterface)
{
AppendSlotTypeDef(sb, method);
sb.Indent();
sb.AppendLine();
sb.Append("static uint16_t");
sb.Append(" __getslot__");
sb.Append(GetCppMethodName(method));
sb.Append("(void * pThis)");
sb.AppendLine();
sb.Append("{");
sb.Indent();
sb.AppendLine();
sb.Append("return ");
sb.Append(slot);
sb.Append(";");
sb.AppendLine();
}
else
{
AppendSlotTypeDef(sb, method);
sb.Indent();
sb.AppendLine();
sb.Append("static __slot__");
sb.Append(GetCppMethodName(method));
sb.Append(" __getslot__");
sb.Append(GetCppMethodName(method));
sb.Append("(void * pThis)");
sb.AppendLine();
sb.Append("{");
sb.Indent();
sb.AppendLine();
sb.Append(" return (__slot__");
sb.Append(GetCppMethodName(method));
sb.Append(")*((void **)(*((RawEEType **)pThis) + 1) + ");
sb.Append(slot.ToStringInvariant());
sb.Append(");");
}
sb.Exdent();
sb.AppendLine();
sb.Append("};");
sb.Exdent();
return sb.ToString();
}
示例6: GetCodeForReadyToRunHeader
private String GetCodeForReadyToRunHeader(ReadyToRunHeaderNode headerNode, NodeFactory factory)
{
CppGenerationBuffer rtrHeader = new CppGenerationBuffer();
rtrHeader.Append(GetCodeForObjectNode(headerNode, factory));
rtrHeader.AppendLine();
rtrHeader.Append("void* RtRHeaderWrapper() {");
rtrHeader.Indent();
rtrHeader.AppendLine();
rtrHeader.Append("static struct {");
rtrHeader.AppendLine();
rtrHeader.Append("unsigned char leftPadding[8];");
rtrHeader.AppendLine();
rtrHeader.Append("void* rtrHeader;");
rtrHeader.AppendLine();
rtrHeader.Append("unsigned char rightPadding[8];");
rtrHeader.AppendLine();
rtrHeader.Append("} rtrHeaderWrapper = {");
rtrHeader.Indent();
rtrHeader.AppendLine();
rtrHeader.Append("{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },");
rtrHeader.AppendLine();
rtrHeader.Append("(void*)");
rtrHeader.Append(headerNode.GetMangledName());
rtrHeader.Append("(),");
rtrHeader.AppendLine();
rtrHeader.Append("{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }");
rtrHeader.AppendLine();
rtrHeader.Append("};");
rtrHeader.Exdent();
rtrHeader.AppendLine();
rtrHeader.Append("return (void *)&rtrHeaderWrapper;");
rtrHeader.Exdent();
rtrHeader.AppendLine();
rtrHeader.Append("}");
rtrHeader.AppendLine();
return rtrHeader.ToString();
}
示例7: OutputCode
public void OutputCode(IEnumerable<DependencyNode> nodes, NodeFactory factory)
{
BuildMethodLists(nodes);
Out.WriteLine("#include \"common.h\"");
Out.WriteLine("#include \"CppCodeGen.h\"");
Out.WriteLine();
_statics = new CppGenerationBuffer();
_statics.Indent();
_gcStatics = new CppGenerationBuffer();
_gcStatics.Indent();
_threadStatics = new CppGenerationBuffer();
_threadStatics.Indent();
_gcThreadStatics = new CppGenerationBuffer();
_gcThreadStatics.Indent();
OutputNodes(nodes, factory);
Out.Write("struct {");
Out.Write(_statics.ToString());
Out.Write("} __statics;");
Out.Write("struct {");
Out.Write(_gcStatics.ToString());
Out.Write("} __gcStatics;");
Out.Write("struct {");
Out.Write(_gcStatics.ToString());
Out.Write("} __gcThreadStatics;");
OutputExternCSignatures();
foreach (var node in nodes)
{
if (node is CppMethodCodeNode)
OutputMethodNode(node as CppMethodCodeNode);
}
Out.Dispose();
}
示例8: CompileMethod
public void CompileMethod(CppMethodCodeNode methodCodeNodeNeedingCode)
{
MethodDesc method = methodCodeNodeNeedingCode.Method;
_compilation.Log.WriteLine("Compiling " + method.ToString());
SpecialMethodKind kind = method.DetectSpecialMethodKind();
if (kind != SpecialMethodKind.Unknown)
{
string specialMethodCode = CompileSpecialMethod(method, kind);
methodCodeNodeNeedingCode.SetCode(specialMethodCode, Array.Empty<Object>());
return;
}
var methodIL = _compilation.GetMethodIL(method);
if (methodIL == null)
return;
try
{
var ilImporter = new ILImporter(_compilation, this, method, methodIL);
CompilerTypeSystemContext typeSystemContext = _compilation.TypeSystemContext;
if (!_compilation.Options.NoLineNumbers)
{
IEnumerable<ILSequencePoint> sequencePoints = typeSystemContext.GetSequencePointsForMethod(method);
if (sequencePoints != null)
ilImporter.SetSequencePoints(sequencePoints);
}
IEnumerable<ILLocalVariable> localVariables = typeSystemContext.GetLocalVariableNamesForMethod(method);
if (localVariables != null)
ilImporter.SetLocalVariables(localVariables);
IEnumerable<string> parameters = typeSystemContext.GetParameterNamesForMethod(method);
if (parameters != null)
ilImporter.SetParameterNames(parameters);
ilImporter.Compile(methodCodeNodeNeedingCode);
}
catch (Exception e)
{
_compilation.Log.WriteLine(e.Message + " (" + method + ")");
var builder = new CppGenerationBuffer();
builder.AppendLine();
builder.Append(GetCppMethodDeclaration(method, true));
builder.AppendLine();
builder.Append("{");
builder.Indent();
builder.AppendLine();
builder.Append("throw 0xC000C000;");
builder.Exdent();
builder.AppendLine();
builder.Append("}");
methodCodeNodeNeedingCode.SetCode(builder.ToString(), Array.Empty<Object>());
}
}
示例9: GetCppMethodDeclaration
public string GetCppMethodDeclaration(MethodDesc method, bool implementation, string externalMethodName = null, MethodSignature methodSignature = null)
{
var sb = new CppGenerationBuffer();
if (methodSignature == null)
methodSignature = method.Signature;
if (externalMethodName != null)
{
sb.Append("extern \"C\" ");
}
else
{
if (!implementation)
{
sb.Append("static ");
}
}
sb.Append(GetCppSignatureTypeName(methodSignature.ReturnType));
sb.Append(" ");
if (externalMethodName != null)
{
sb.Append(externalMethodName);
}
else
{
if (implementation)
{
sb.Append(GetCppMethodDeclarationName(method.OwningType, GetCppMethodName(method)));
}
else
{
sb.Append(GetCppMethodName(method));
}
}
sb.Append("(");
bool hasThis = !methodSignature.IsStatic;
int argCount = methodSignature.Length;
if (hasThis)
argCount++;
List<string> parameterNames = null;
if (method != null)
{
IEnumerable<string> parameters = GetParameterNamesForMethod(method);
if (parameters != null)
{
parameterNames = new List<string>(parameters);
if (parameterNames.Count != 0)
{
System.Diagnostics.Debug.Assert(parameterNames.Count == argCount);
}
else
{
parameterNames = null;
}
}
}
for (int i = 0; i < argCount; i++)
{
if (hasThis)
{
if (i == 0)
{
var thisType = method.OwningType;
if (thisType.IsValueType)
thisType = thisType.MakeByRefType();
sb.Append(GetCppSignatureTypeName(thisType));
}
else
{
sb.Append(GetCppSignatureTypeName(methodSignature[i - 1]));
}
}
else
{
sb.Append(GetCppSignatureTypeName(methodSignature[i]));
}
if (implementation)
{
sb.Append(" ");
if (parameterNames != null)
{
sb.Append(SanitizeCppVarName(parameterNames[i]));
}
else
{
sb.Append("_a");
sb.Append(i.ToStringInvariant());
}
}
if (i != argCount - 1)
sb.Append(", ");
}
sb.Append(")");
if (!implementation)
sb.Append(";");
//.........这里部分代码省略.........
示例10: OutputTypes
private void OutputTypes(bool full)
{
var sb = new CppGenerationBuffer();
if (full)
{
_statics = new CppGenerationBuffer();
_statics.Indent();
_gcStatics = new CppGenerationBuffer();
_gcStatics.Indent();
_threadStatics = new CppGenerationBuffer();
_threadStatics.Indent();
_gcThreadStatics = new CppGenerationBuffer();
_gcThreadStatics.Indent();
}
_emittedTypes = new HashSet<TypeDesc>();
foreach (var t in _cppSignatureNames.Keys)
{
if (t.IsByRef || t.IsPointer)
continue;
// Base class types and valuetype instantance field types may be emitted out-of-order to make them
// appear before they are used.
if (_emittedTypes.Contains(t))
continue;
OutputType(sb, t, full);
}
_emittedTypes = null;
if (full)
{
sb.AppendLine();
sb.Append("struct {");
// No need to indent or add a new line as _statics is already properly indented
sb.Append(_statics.ToString());
sb.AppendLine();
sb.Append("} __statics;");
// TODO: Register GC statics with GC
sb.AppendLine();
sb.Append("struct {");
// No need to indent or add a new line as _gcStatics is already properly indented
sb.Append(_gcStatics.ToString());
sb.AppendLine();
sb.Append("} __gcStatics;");
sb.AppendLine();
// @TODO_SDM: do for real - note: the 'extra' series are just testing the init syntax for 0-length arrays, they should be removed
// TODO: preinitialized 0-length arrays are not supported in CLang
sb.Append("#ifdef _MSC_VER");
sb.AppendLine();
sb.Append("StaticGcDesc __gcStaticsDescs = { 1, { { sizeof(__gcStatics), 0 }, { 123, 456 }, { 789, 101112 } } };");
sb.AppendLine();
sb.Append("#else");
sb.AppendLine();
sb.Append("StaticGcDesc __gcStaticsDescs;");
sb.AppendLine();
sb.Append("#endif");
sb.AppendLine();
sb.Append("SimpleModuleHeader __module = { &__gcStatics, &__gcStaticsDescs };");
_statics = null;
_gcStatics = null;
_threadStatics = null;
_gcThreadStatics = null;
}
Out.Write(sb.ToString());
sb.Clear();
}
示例11: CompileSpecialMethod
private string CompileSpecialMethod(MethodDesc method, SpecialMethodKind kind)
{
var builder = new CppGenerationBuffer();
switch (kind)
{
case SpecialMethodKind.PInvoke:
case SpecialMethodKind.RuntimeImport:
{
EcmaMethod ecmaMethod = method as EcmaMethod;
string importName = kind == SpecialMethodKind.PInvoke ?
method.GetPInvokeMethodMetadata().Name : ecmaMethod.GetAttributeStringValue("System.Runtime", "RuntimeImportAttribute");
if (importName == null)
importName = method.Name;
MethodSignature methodSignature = method.Signature;
bool slotCastRequired = false;
MethodSignature externCSignature;
if (_externCSignatureMap.TryGetValue(importName, out externCSignature))
{
slotCastRequired = !externCSignature.Equals(method.Signature);
}
else
{
_externCSignatureMap.Add(importName, methodSignature);
externCSignature = methodSignature;
}
builder.AppendLine();
builder.Append(GetCppMethodDeclaration(method, true));
builder.AppendLine();
builder.Append("{");
builder.Indent();
if (slotCastRequired)
{
AppendSlotTypeDef(builder, method);
}
builder.AppendLine();
if (!method.Signature.ReturnType.IsVoid)
{
builder.Append("return ");
}
if (slotCastRequired)
builder.Append("((__slot__" + GetCppMethodName(method) + ")");
builder.Append("::");
builder.Append(importName);
if (slotCastRequired)
builder.Append(")");
builder.Append("(");
builder.Append(GetCppMethodCallParamList(method));
builder.Append(");");
builder.Exdent();
builder.AppendLine();
builder.Append("}");
return builder.ToString();
}
default:
builder.AppendLine();
builder.Append(GetCppMethodDeclaration(method, true));
builder.AppendLine();
builder.Append("{");
builder.Indent();
builder.AppendLine();
builder.Append("throw 0xC000C000;");
builder.Exdent();
builder.AppendLine();
builder.Append("}");
return builder.ToString();
}
}
示例12: OutputMainMethodStub
private void OutputMainMethodStub(MethodDesc entrypoint)
{
var sb = new CppGenerationBuffer();
sb.AppendLine();
if (_compilation.TypeSystemContext.Target.OperatingSystem == TargetOS.Windows)
{
sb.Append("int wmain(int argc, wchar_t * argv[]) { ");
}
else
{
sb.Append("int main(int argc, char * argv[]) {");
}
sb.Indent();
sb.AppendLine();
sb.Append("if (__initialize_runtime() != 0)");
sb.Indent();
sb.AppendLine();
sb.Append("return -1;");
sb.Exdent();
sb.AppendEmptyLine();
sb.AppendLine();
sb.Append("ReversePInvokeFrame frame;");
sb.AppendLine();
sb.Append("__reverse_pinvoke(&frame);");
sb.AppendEmptyLine();
sb.AppendLine();
sb.Append("::System_Private_CoreLib::Internal::Runtime::CompilerHelpers::StartupCodeHelpers::InitializeModules((intptr_t)RtRHeaderWrapper(), 2);");
sb.AppendLine();
sb.Append("int ret = ");
sb.Append(GetCppMethodDeclarationName(entrypoint.OwningType, GetCppMethodName(entrypoint)));
sb.Append("(argc, (intptr_t)argv);");
sb.AppendEmptyLine();
sb.AppendLine();
sb.Append("__reverse_pinvoke_return(&frame);");
sb.AppendLine();
sb.Append("__shutdown_runtime();");
sb.AppendLine();
sb.Append("return ret;");
sb.Exdent();
sb.AppendLine();
sb.Append("}");
Out.Write(sb.ToString());
}
示例13: OutputCode
public void OutputCode(IEnumerable<DependencyNode> nodes, NodeFactory factory)
{
BuildMethodLists(nodes);
Out.WriteLine("#include \"common.h\"");
Out.WriteLine("#include \"CppCodeGen.h\"");
Out.WriteLine();
_statics = new CppGenerationBuffer();
_statics.Indent();
_gcStatics = new CppGenerationBuffer();
_gcStatics.Indent();
_threadStatics = new CppGenerationBuffer();
_threadStatics.Indent();
_gcThreadStatics = new CppGenerationBuffer();
_gcThreadStatics.Indent();
OutputNodes(nodes, factory);
Out.Write("struct {");
Out.Write(_statics.ToString());
Out.Write("} __statics;");
Out.Write("struct {");
Out.Write(_gcStatics.ToString());
Out.Write("} __gcStatics;");
Out.Write("struct {");
Out.Write(_gcStatics.ToString());
Out.Write("} __gcThreadStatics;");
OutputExternCSignatures();
foreach (var node in nodes)
{
if (node is CppMethodCodeNode)
OutputMethodNode(node as CppMethodCodeNode);
}
// Try to locate the entrypoint method
MethodDesc entrypoint = null;
foreach (var alias in factory.NodeAliases)
if (alias.Value == MainMethodRootProvider.ManagedEntryPointMethodName)
entrypoint = ((IMethodNode)alias.Key).Method;
if (entrypoint != null)
{
OutputMainMethodStub(entrypoint);
}
Out.Dispose();
}
示例14: ImportCall
//.........这里部分代码省略.........
}
}
else
{
needNewLine = true;
}
if (opcode == ILOpcode.newobj && !mdArrayCreate)
{
if (!retType.IsValueType)
{
// We do not reset needNewLine since we still need for the next statement.
if (needNewLine)
AppendLine();
Append("__allocate_object(");
Append(_writer.GetCppTypeName(retType));
Append("::__getMethodTable())");
AppendSemicolon();
needNewLine = true;
if (delegateInfo != null && delegateInfo.ShuffleThunk != null)
{
AddMethodReference(delegateInfo.ShuffleThunk);
_stack[_stackTop - 2].Value.Name = temp;
var sb = new CppGenerationBuffer();
AppendLine();
sb.Append("(intptr_t)&");
sb.Append(_writer.GetCppTypeName(delegateInfo.ShuffleThunk.OwningType));
sb.Append("::");
sb.Append(_writer.GetCppMethodName(delegateInfo.ShuffleThunk));
Push(StackValueKind.NativeInt, new Value(sb.ToString()), null);
}
}
}
if (needNewLine)
AppendLine();
if (callViaSlot || delegateInvoke)
{
Append("(*");
Append(_writer.GetCppTypeName(method.OwningType));
Append("::");
Append(delegateInvoke ? "__invoke__" : "__getslot__");
Append(_writer.GetCppMethodName(method));
Append("(");
Append(_stack[_stackTop - (methodSignature.Length + 1)].Value.Name);
Append("))");
if (delegateInvoke)
{
_stack[_stackTop - (methodSignature.Length + 1)].Value.Name =
"((" + _writer.GetCppSignatureTypeName(GetWellKnownType(WellKnownType.MulticastDelegate)) + ")" +
_stack[_stackTop - (methodSignature.Length + 1)].Value.Name + ")->m_firstParameter";
}
}
else if (mdArrayCreate)
{
Append("RhNewMDArray");
}
else
{
Append(_writer.GetCppTypeName(method.OwningType));
示例15: ImportCall
//.........这里部分代码省略.........
else
{
needNewLine = true;
}
if (opcode == ILOpcode.newobj && !mdArrayCreate)
{
if (!retType.IsValueType)
{
// We do not reset needNewLine since we still need for the next statement.
if (needNewLine)
AppendLine();
Append("__allocate_object(");
Append(_writer.GetCppTypeName(retType));
Append("::__getMethodTable())");
AppendSemicolon();
needNewLine = true;
if (delegateInfo != null && delegateInfo.Thunk != null)
{
MethodDesc thunkMethod = delegateInfo.Thunk.Method;
AddMethodReference(thunkMethod);
// Update stack with new name.
((ExpressionEntry) _stack[_stack.Top - 2]).Name = temp;
var sb = new CppGenerationBuffer();
AppendLine();
sb.Append("(intptr_t)&");
sb.Append(_writer.GetCppTypeName(thunkMethod.OwningType));
sb.Append("::");
sb.Append(_writer.GetCppMethodName(thunkMethod));
PushExpression(StackValueKind.NativeInt, sb.ToString());
}
}
}
if (needNewLine)
AppendLine();
if (callViaSlot || delegateInvoke)
{
// While waiting for C# return by ref, get this reference and insert it back
// if it is a delegate invoke.
ExpressionEntry v = (ExpressionEntry) _stack[_stack.Top - (methodSignature.Length + 1)];
Append("(*");
Append(_writer.GetCppTypeName(method.OwningType));
Append("::");
Append(delegateInvoke ? "__invoke__" : "__getslot__");
Append(_writer.GetCppMethodName(method));
Append("(");
Append(v);
Append("))");
if (delegateInvoke)
{
v.Name =
"((" + _writer.GetCppSignatureTypeName(GetWellKnownType(WellKnownType.MulticastDelegate)) + ")" +
v.Name + ")->m_firstParameter";
}
}
else if (mdArrayCreate)
{
Append("RhNewMDArray");
}