PageRenderTime 71ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/DICK.B1/IronPython/Compiler/Ast/AstMethods.cs

https://bitbucket.org/williamybs/uidipythontool
C# | 102 lines | 83 code | 5 blank | 14 comment | 0 complexity | 02e169542a5db703854a72d0cc8b47a0 MD5 | raw file
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Microsoft Public License. A
  6. * copy of the license can be found in the License.html file at the root of this distribution. If
  7. * you cannot locate the Microsoft Public License, please send an email to
  8. * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound
  9. * by the terms of the Microsoft Public License.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. using System;
  16. using System.Collections;
  17. using System.Collections.Generic;
  18. using System.Reflection;
  19. using Microsoft.Scripting;
  20. using Microsoft.Scripting.Runtime;
  21. using Microsoft.Scripting.Utils;
  22. using IronPython.Runtime;
  23. using IronPython.Runtime.Operations;
  24. namespace IronPython.Compiler.Ast {
  25. static class AstMethods {
  26. public static readonly MethodInfo IsTrue = GetMethod((Func<object, bool>)PythonOps.IsTrue);
  27. public static readonly MethodInfo RaiseAssertionError = GetMethod((Action<object>)PythonOps.RaiseAssertionError);
  28. public static readonly MethodInfo Repr = GetMethod((Func<CodeContext, object, string>)PythonOps.Repr);
  29. public static readonly MethodInfo WarnDivision = GetMethod((Action<CodeContext, PythonDivisionOptions, object, object>)PythonOps.WarnDivision);
  30. public static readonly MethodInfo MakeClass = GetMethod((Func<object, CodeContext, string, object[], string, object>)PythonOps.MakeClass);
  31. public static readonly MethodInfo UnqualifiedExec = GetMethod((Action<CodeContext, object>)PythonOps.UnqualifiedExec);
  32. public static readonly MethodInfo QualifiedExec = GetMethod((Action<CodeContext, object, PythonDictionary, object>)PythonOps.QualifiedExec);
  33. public static readonly MethodInfo PrintExpressionValue = GetMethod((Action<CodeContext, object>)PythonOps.PrintExpressionValue);
  34. public static readonly MethodInfo PrintCommaWithDest = GetMethod((Action<CodeContext, object, object>)PythonOps.PrintCommaWithDest);
  35. public static readonly MethodInfo PrintWithDest = GetMethod((Action<CodeContext, object, object>)PythonOps.PrintWithDest);
  36. public static readonly MethodInfo PrintComma = GetMethod((Action<CodeContext, object>)PythonOps.PrintComma);
  37. public static readonly MethodInfo Print = GetMethod((Action<CodeContext, object>)PythonOps.Print);
  38. public static readonly MethodInfo ImportWithNames = GetMethod((Func<CodeContext, string, string[], int, object>)PythonOps.ImportWithNames);
  39. public static readonly MethodInfo ImportFrom = GetMethod((Func<CodeContext, object, string, object>)PythonOps.ImportFrom);
  40. public static readonly MethodInfo ImportStar = GetMethod((Action<CodeContext, string, int>)PythonOps.ImportStar);
  41. public static readonly MethodInfo SaveCurrentException = GetMethod((Func<Exception>)PythonOps.SaveCurrentException);
  42. public static readonly MethodInfo RestoreCurrentException = GetMethod((Action<Exception>)PythonOps.RestoreCurrentException);
  43. public static readonly MethodInfo MakeGeneratorExpression = GetMethod((Func<object, object, object>)PythonOps.MakeGeneratorExpression);
  44. public static readonly MethodInfo ListAddForComprehension = GetMethod((Action<List, object>)PythonOps.ListAddForComprehension);
  45. public static readonly MethodInfo MakeEmptyListFromCode = GetMethod((Func<List>)PythonOps.MakeEmptyListFromCode);
  46. public static readonly MethodInfo CheckUninitialized = GetMethod((Func<object, string, object>)PythonOps.CheckUninitialized);
  47. public static readonly MethodInfo PrintNewlineWithDest = GetMethod((Action<CodeContext, object>)PythonOps.PrintNewlineWithDest);
  48. public static readonly MethodInfo PrintNewline = GetMethod((Action<CodeContext>)PythonOps.PrintNewline);
  49. public static readonly MethodInfo PublishModule = GetMethod((Func<CodeContext, string, object>)PythonOps.PublishModule);
  50. public static readonly MethodInfo RemoveModule = GetMethod((Action<CodeContext, string, object>)PythonOps.RemoveModule);
  51. public static readonly MethodInfo ModuleStarted = GetMethod((Action<CodeContext, ModuleOptions>)PythonOps.ModuleStarted);
  52. public static readonly MethodInfo MakeRethrownException = GetMethod((Func<CodeContext, Exception>)PythonOps.MakeRethrownException);
  53. public static readonly MethodInfo MakeRethrowExceptionWorker = GetMethod((Func<Exception, Exception>)PythonOps.MakeRethrowExceptionWorker);
  54. public static readonly MethodInfo MakeException = GetMethod((Func<CodeContext, object, object, object, Exception>)PythonOps.MakeException);
  55. public static readonly MethodInfo MakeSlice = GetMethod((Func<object, object, object, Slice>)PythonOps.MakeSlice);
  56. public static readonly MethodInfo ExceptionHandled = GetMethod((Action<CodeContext>)PythonOps.ExceptionHandled);
  57. public static readonly MethodInfo GetAndClearDynamicStackFrames = GetMethod((Func<List<DynamicStackFrame>>)PythonOps.GetAndClearDynamicStackFrames);
  58. public static readonly MethodInfo SetDynamicStackFrames = GetMethod((Action<List<DynamicStackFrame>>)PythonOps.SetDynamicStackFrames);
  59. public static readonly MethodInfo GetExceptionInfoLocal = GetMethod((Func<CodeContext, Exception, PythonTuple>)PythonOps.GetExceptionInfoLocal);
  60. public static readonly MethodInfo CheckException = GetMethod((Func<CodeContext, object, object, object>)PythonOps.CheckException);
  61. public static readonly MethodInfo SetCurrentException = GetMethod((Func<CodeContext, Exception, object>)PythonOps.SetCurrentException);
  62. public static readonly MethodInfo BuildExceptionInfo = GetMethod((Action<CodeContext, Exception>)PythonOps.BuildExceptionInfo);
  63. public static readonly MethodInfo MakeTuple = GetMethod((Func<object[], PythonTuple>)PythonOps.MakeTuple);
  64. public static readonly MethodInfo IsNot = GetMethod((Func<object, object, object>)PythonOps.IsNot);
  65. public static readonly MethodInfo Is = GetMethod((Func<object, object, object>)PythonOps.Is);
  66. public static readonly MethodInfo ImportTop = GetMethod((Func<CodeContext, string, int, object>)PythonOps.ImportTop);
  67. public static readonly MethodInfo ImportBottom = GetMethod((Func<CodeContext, string, int, object>)PythonOps.ImportBottom);
  68. public static readonly MethodInfo MakeList = GetMethod((Func<List>)PythonOps.MakeList);
  69. public static readonly MethodInfo MakeListNoCopy = GetMethod((Func<object[], List>)PythonOps.MakeListNoCopy);
  70. public static readonly MethodInfo GetEnumeratorValues = GetMethod((Func<CodeContext, object, int, object[]>)PythonOps.GetEnumeratorValues);
  71. public static readonly MethodInfo GetGlobalContext = GetMethod((Func<CodeContext, CodeContext>)PythonOps.GetGlobalContext);
  72. public static readonly MethodInfo GetParentContextFromFunction = GetMethod((Func<PythonFunction, CodeContext>)PythonOps.GetParentContextFromFunction);
  73. public static readonly MethodInfo MakeFunction = GetMethod((Func<CodeContext, FunctionCode, object, object[], object>)PythonOps.MakeFunction);
  74. public static readonly MethodInfo MakeFunctionDebug = GetMethod((Func<CodeContext/*!*/, FunctionCode, object, object[], Delegate, object>)PythonOps.MakeFunctionDebug);
  75. public static readonly MethodInfo MakeClosureCell = GetMethod((Func<ClosureCell>)PythonOps.MakeClosureCell);
  76. public static readonly MethodInfo MakeClosureCellWithValue = GetMethod((Func<object, ClosureCell>)PythonOps.MakeClosureCellWithValue);
  77. public static readonly MethodInfo LookupName = GetMethod((Func<CodeContext, string, object>)PythonOps.LookupName);
  78. public static readonly MethodInfo RemoveName = GetMethod((Action<CodeContext, string>)PythonOps.RemoveName);
  79. public static readonly MethodInfo SetName = GetMethod((Func<CodeContext, string, object, object>)PythonOps.SetName);
  80. public static readonly MethodInfo KeepAlive = GetMethod((Action<object>)GC.KeepAlive);
  81. public static readonly MethodInfo MakeDict = GetMethod((Func<int, PythonDictionary>)PythonOps.MakeDict);
  82. public static readonly MethodInfo MakeDictFromItems = GetMethod((Func<object[], PythonDictionary>)PythonOps.MakeDictFromItems);
  83. public static readonly MethodInfo MakeHomogeneousDictFromItems = GetMethod((Func<object[], PythonDictionary>)PythonOps.MakeHomogeneousDictFromItems);
  84. public static readonly MethodInfo CreateLocalContext = GetMethod((Func<CodeContext, MutableTuple, string[], CodeContext>)PythonOps.CreateLocalContext);
  85. public static readonly MethodInfo UpdateStackTrace = GetMethod((Action<CodeContext, FunctionCode, MethodBase, string, string, int>)PythonOps.UpdateStackTrace);
  86. public static readonly MethodInfo GetCurrentMethod = GetMethod((Func<MethodBase>)MethodBase.GetCurrentMethod);
  87. public static readonly MethodInfo ForLoopDispose = GetMethod((Action<KeyValuePair<IEnumerator, IDisposable>>)PythonOps.ForLoopDispose);
  88. public static readonly MethodInfo GetClosureTupleFromContext = GetMethod((Func<CodeContext, MutableTuple>)PythonOps.GetClosureTupleFromContext);
  89. public static readonly MethodInfo IsUnicode = GetMethod((Func<object, bool>)PythonOps.IsUnicode);
  90. public static readonly MethodInfo PushFrame = GetMethod((Func<CodeContext, FunctionCode, List<FunctionStack>>)PythonOps.PushFrame);
  91. public static readonly MethodInfo FormatUnicode = GetMethod((Func<CodeContext, string, object, string>)PythonOps.FormatUnicode);
  92. public static readonly MethodInfo FormatString = GetMethod((Func<CodeContext, string, object, string>)PythonOps.FormatString);
  93. private static MethodInfo GetMethod(Delegate x) {
  94. return x.Method;
  95. }
  96. }
  97. }