本文整理汇总了C#中CodeGen.EmitStringArray方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.EmitStringArray方法的具体用法?C# CodeGen.EmitStringArray怎么用?C# CodeGen.EmitStringArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGen
的用法示例。
在下文中一共展示了CodeGen.EmitStringArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
internal override void Emit(CodeGen cg)
{
Label done = new Label();
bool emitDone = false;
Expression[] exprs = new Expression[args.Length - extraArgs];
Expression argsTuple = null, keywordDict = null;
string[] keywordNames = new string[keywordCount];
int index = 0, keywordIndex = 0;
foreach (Arg arg in args) {
if (arg.Name == SymbolTable.Star) {
argsTuple = arg.Expression; continue;
} else if (arg.Name == SymbolTable.StarStar) {
keywordDict = arg.Expression; continue;
} else if (arg.Name != SymbolTable.Empty) {
keywordNames[keywordIndex++] = arg.Name.GetString();
}
exprs[index++] = arg.Expression;
}
if (hasKeywordDict || (hasArgsTuple && keywordCount > 0)) {
cg.EmitCallerContext();
target.Emit(cg);
cg.EmitObjectArray(exprs);
cg.EmitStringArray(keywordNames);
cg.EmitExprOrNone(argsTuple);
cg.EmitExprOrNone(keywordDict);
cg.EmitCall(typeof(Ops), "CallWithArgsTupleAndKeywordDictAndContext",
new Type[] { typeof(ICallerContext), typeof(object), typeof(object[]), typeof(string[]),
typeof(object), typeof(object)});
} else if (hasArgsTuple) {
cg.EmitCallerContext();
target.Emit(cg);
cg.EmitObjectArray(exprs);
cg.EmitExprOrNone(argsTuple);
cg.EmitCall(typeof(Ops), "CallWithArgsTupleAndContext",
new Type[] { typeof(ICallerContext), typeof(object), typeof(object[]), typeof(object) });
} else if (keywordCount > 0) {
cg.EmitCallerContext();
target.Emit(cg);
cg.EmitObjectArray(exprs);
cg.EmitStringArray(keywordNames);
cg.EmitCall(typeof(Ops), "Call",
new Type[] { typeof(ICallerContext), typeof(object), typeof(object[]), typeof(string[]) });
} else {
cg.EmitCallerContext();
target.Emit(cg);
if (args.Length <= Ops.MaximumCallArgs) {
Type[] argTypes = new Type[args.Length + 2];
int i = 0;
argTypes[i++] = typeof(ICallerContext);
argTypes[i++] = typeof(object);
foreach (Expression e in exprs) {
e.Emit(cg);
argTypes[i++] = typeof(object);
}
cg.EmitCall(typeof(Ops), "CallWithContext", argTypes);
} else {
cg.EmitObjectArray(exprs);
cg.EmitCall(typeof(Ops), "CallWithContext",
new Type[] { typeof(ICallerContext), typeof(object), typeof(object[]) });
}
}
if (emitDone) {
cg.MarkLabel(done);
}
}
示例2: Emit
internal override void Emit(CodeGen cg)
{
cg.EmitPosition(this);
if (names == star) {
cg.EmitCallerContext();
cg.EmitString(root.MakeString());
cg.EmitCall(typeof(Ops), "ImportStar");
} else {
cg.EmitModuleInstance();
cg.EmitString(root.MakeString());
Slot fromObj = cg.GetLocalTmp(typeof(object));
cg.EmitStringArray(SymbolTable.IdsToStrings(names));
if (asNames != null) {
cg.EmitStringArray(SymbolTable.IdsToStrings(asNames));
cg.EmitCall(typeof(Ops), "ImportFromAs");
} else {
cg.EmitCall(typeof(Ops), "ImportFrom");
}
fromObj.EmitSet(cg);
for (int i = 0; i < names.Count; i++) {
cg.EmitCallerContext();
fromObj.EmitGet(cg);
cg.EmitString(names[i].GetString());
cg.EmitCall(typeof(Ops), "ImportOneFrom");
SymbolId asName;
if (i < asNames.Count && asNames[i] != SymbolTable.Empty)
asName = asNames[i];
else
asName = names[i];
cg.EmitSet(asName);
}
}
}
示例3: EmitModuleConstruction
/// <summary>
/// Emits a call into the PythonModule to register this module, and then
/// returns the resulting PythonModule
/// </summary>
public static void EmitModuleConstruction(TypeGen tg, CodeGen main, string moduleName, Slot initialize, IList<string> referencedAssemblies)
{
// calling PythonModule InitializeModule(CustomDict compiled, string fullName)
main.EmitNew(tg.DefaultConstructor); // Emit instance for the InitializeModule call (compiled)
initialize.EmitSet(main);
initialize.EmitGet(main);
main.EmitString(moduleName); // emit module name (fullName)
// emit the references assemblies
if (referencedAssemblies != null) {
for (int i = 0; i < referencedAssemblies.Count; i++) {
if (referencedAssemblies[i].ToLower().EndsWith("\\ironpython.dll")) {
referencedAssemblies.RemoveAt(i);
i--;
} else {
if (referencedAssemblies[i].IndexOf(Path.DirectorySeparatorChar) != -1) {
referencedAssemblies[i] = referencedAssemblies[i].Substring(referencedAssemblies[i].LastIndexOf(Path.DirectorySeparatorChar) + 1);
}
if (referencedAssemblies[i].ToLower().EndsWith(".dll")) {
referencedAssemblies[i] = referencedAssemblies[i].Substring(0, referencedAssemblies[i].Length - 4);
}
}
}
main.EmitStringArray(referencedAssemblies);
} else main.Emit(OpCodes.Ldnull);
// Call InitializeModule
main.EmitCall(typeof(Ops), "InitializeModule");
}