本文整理汇总了C#中IronPython类的典型用法代码示例。如果您正苦于以下问题:C# IronPython类的具体用法?C# IronPython怎么用?C# IronPython使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IronPython类属于命名空间,在下文中一共展示了IronPython类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CodeSpan
internal CodeSpan(IronPython.Compiler.Location start, IronPython.Compiler.Location end)
{
this.startLine = start.Line;
this.startColumn = start.Column;
this.endLine = end.Line;
this.endColumn = end.Column;
}
示例2: MakeGroup
public static DomainEntityCollection<Relationship> MakeGroup(IronPython.Runtime.List lst)
{
DomainEntityCollection<Relationship> retval = new DomainEntityCollection<Relationship>();
foreach (var c in lst)
{
retval.Add(new Relationship(null) { Code = (string)c });
}
return retval;
}
示例3: PerformModuleReload
public static void PerformModuleReload(
IronPython.Runtime.PythonContext context,
IronPython.Runtime.PythonDictionary dict)
{
context.DomainManager.LoadAssembly(typeof(System.Xml.Linq.XDocument).Assembly);
dict["FOO"] = "bar";
System.Console.WriteLine("Module Load");
}
示例4: get_state
public static object get_state(IronPython.Runtime.CodeContext context, object value)
{
object prev_value = null;
if (context.LanguageContext.HasModuleState(_stateKey))
{
prev_value = context.LanguageContext.GetModuleState(_stateKey);
}
context.LanguageContext.SetModuleState(_stateKey, value);
return prev_value;
}
示例5: ILArgumentException
public IronPython.Runtime.List this[IronPython.Runtime.Slice xslice, IronPython.Runtime.Slice yslice]
{
get
{
if ((xslice.start == null) || (xslice.stop == null) || (yslice.start == null) || (yslice.stop == null))
{
throw new ILArgumentException("mgrid: start and stop of slices must be provided");
}
double xStep = 1, yStep = 1, xStart = 0, yStart = 0, xStop = 1, yStop = 1;
//
if (xslice.start is int) xStart = (double)(int)(xslice.start);
if (xslice.start is double) xStart = (double)(xslice.start);
if (xslice.stop is int) xStop = (double)(int)(xslice.stop);
if (xslice.stop is double) xStop = (double)(xslice.stop);
//
if (yslice.start is int) yStart = (double)(int)(yslice.start);
if (yslice.start is double) yStart = (double)(yslice.start);
if (yslice.stop is int) yStop = (double)(int)(yslice.stop);
if (yslice.stop is double) yStop = (double)(yslice.stop);
//
if (xslice.step == null)
{
if (xStop >= xStart) xStep = 1;
else xStep = -1;
}
else
{
if (xslice.step is int) xStep = (double)(int)(xslice.step);
if (xslice.step is double) xStep = (double)(xslice.step);
}
if (yslice.step == null)
{
if (yStop >= yStart) yStep = 1;
else yStep = -1;
}
else
{
if (yslice.step is int) yStep = (double)(int)(yslice.step);
if (yslice.step is double) yStep = (double)(yslice.step);
}
//
IronPython.Runtime.List list = new IronPython.Runtime.List();
int nx = (int)Math.Floor((xStop - xStart) / xStep) + 1;
int ny = (int)Math.Floor((yStop - yStart) / yStep) + 1;
ILArray<double> x = ILMath.counter(xStart, xStep, nx);
ILArray<double> y = ILMath.counter(yStart, yStep, ny);
List<ILArray<double>> meshgrid = ILMath.meshgrid(x, y);
list.Add(meshgrid[0]); list.Add(meshgrid[1]);
return list;
}
}
示例6: array
/// <summary>
/// Convert IronPython List into ILBaseArray
/// </summary>
/// <param name="list">IronPython List (must be filled with Python ints or floats)</param>
/// <returns>ILBaseArray</returns>
public static ILBaseArray array(IronPython.Runtime.List list)
{
List<int> size = new List<int>();
Type type = typeof(double);
PythonListHelper.GetListDimensionsAndType(ref size, list, ref type);
if (!PythonListHelper.CheckList(ref size, list, 0, ref type))
{
throw new ArgumentException("List is not rectangular or not of constant type!");
}
if (type == typeof(Double))
{
return new ILArray<Double>(list);
}
else if (type == typeof(Int32))
{
return new ILArray<Int32>(list);
}
else throw new ArgumentException("List type is not int or float");
}
示例7: List_to_ComplexArray
internal static ComplexF[] List_to_ComplexArray(IronPython.Runtime.List list_object)
{
ComplexF[] _fft = new ComplexF[list_object.Count];
for (int i = 0 ; i < _fft.Length ; i++)
{
try
{
if (list_object[i].GetType() == typeof(System.Numerics.Complex))
{
System.Numerics.Complex c = (System.Numerics.Complex)list_object[i];
_fft[i] = new ComplexF((float)c.Real, (float)c.Imaginary);
}
else
{
_fft[i] = new ComplexF(float.Parse(list_object[i].ToString()), 0);
}
} catch (Exception)
{
throw;
}
}
return _fft;
}
示例8: WalkLoopBody
private void WalkLoopBody(IronPython.Compiler.Ast.Statement body, bool isFinally) {
bool inLoop = _inLoop;
bool inFinally = _inFinally;
int loopId = ++_loopId;
_inFinally = false;
_inLoop = true;
_loopIds.Add(loopId, isFinally);
body.Walk(this);
_inLoop = inLoop;
_inFinally = inFinally;
LoopOrFinallyIds.Remove(loopId);
}
示例9: AddError
/// <summary>
/// Log Errors/Warnings/Messages when the compiler reports them.
/// </summary>
/// <param name="path">Path to the file where the error was found (null/empty if N/A)</param>
/// <param name="message">Text of the error/warning/message</param>
/// <param name="startLine">First line of the block containing the error (0 if N/A)</param>
/// <param name="startColumn">First column of the block containing the error (0 if N/A)</param>
/// <param name="endLine">Last line of the block containing the error (0 if N/A)</param>
/// <param name="endColumn">Last column of the block containing the error (0 if N/A)</param>
/// <param name="errorCode">Code corresponding to the error</param>
/// <param name="severity">Error/Warning/Message</param>
public override void AddError(string path, string message, string lineText, IronPython.Hosting.CodeSpan location, int errorCode, IronPython.Hosting.Severity severity)
{
if (ProjectDirectory != null && !System.IO.Path.IsPathRooted(path))
path = System.IO.Path.Combine(ProjectDirectory, path);
// Based on the type of event (error/warning/message), report the corresponding type of problem to MSBuild
switch(severity)
{
case IronPython.Hosting.Severity.Error:
{
buildSucceeded = false;
taskLogger.LogError(String.Empty, "PY" + errorCode.ToString(), String.Empty, path, location.StartLine, location.StartColumn, location.EndLine, location.EndColumn, message);
break;
}
case IronPython.Hosting.Severity.Warning:
{
taskLogger.LogWarning(String.Empty, "PY" + errorCode.ToString(), String.Empty, path, location.StartLine, location.StartColumn, location.EndLine, location.EndColumn, message);
break;
}
case IronPython.Hosting.Severity.Message:
{
taskLogger.LogMessage(message);
break;
}
}
}
示例10: Analyze
public void Analyze(IronPython.Compiler.Ast.FunctionDefinition function)
{
this.argument = 0;
this.function = function;
foreach (Expression param in function.Parameters) {
param.Walk(this);
argument++;
}
}
示例11: ExperimentalCompiler
public ExperimentalCompiler(IList<string> sourcesFiles, string outputAssembly, IronPython.Hosting.CompilerSink compilerSink)
{
this.sourceFiles = (List<string>)sourcesFiles;
this.outputAssembly = outputAssembly;
this.errorSink = compilerSink;
}
示例12: keyword
internal keyword(IronPython.Compiler.Ast.Arg arg)
: this() {
_arg = arg.Name;
_value = Convert(arg.Expression);
}
示例13: FunctionDefinitionInfo
public FunctionDefinitionInfo(IronPython.Compiler.Ast.FunctionDefinition function)
{
this.function = function;
}
示例14: Walk
public override bool Walk(IronPython.Compiler.Ast.FunctionDefinition node) {
UpdateLoops(node);
return base.Walk(node);
}
示例15: PostWalk
public override void PostWalk(IronPython.Compiler.Ast.FunctionDefinition node)
{
PopScope();
}