PageRenderTime 41ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/IronPython_Main/Languages/IronPython/IronPython/Compiler/Ast/Arg.cs

#
C# | 71 lines | 47 code | 10 blank | 14 comment | 12 complexity | 48cddfa1fdbd172b043c5a18779bad15 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, CPL-1.0, CC-BY-SA-3.0, BSD-3-Clause, ISC, AGPL-3.0, LGPL-2.1, Apache-2.0
  1. /* ****************************************************************************
  2. *
  3. * Copyright (c) Microsoft Corporation.
  4. *
  5. * This source code is subject to terms and conditions of the Apache License, Version 2.0. 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 Apache License, Version 2.0, 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 Apache License, Version 2.0.
  10. *
  11. * You must not remove this notice, or any other, from this software.
  12. *
  13. *
  14. * ***************************************************************************/
  15. #if !CLR2
  16. using MSAst = System.Linq.Expressions;
  17. #else
  18. using MSAst = Microsoft.Scripting.Ast;
  19. #endif
  20. using IronPython.Runtime;
  21. using Microsoft.Scripting;
  22. using Microsoft.Scripting.Actions;
  23. namespace IronPython.Compiler.Ast {
  24. public class Arg : Node {
  25. private readonly string _name;
  26. private readonly Expression _expression;
  27. public Arg(Expression expression) : this(null, expression) { }
  28. public Arg(string name, Expression expression) {
  29. _name = name;
  30. _expression = expression;
  31. }
  32. public string Name {
  33. get { return _name; }
  34. }
  35. public Expression Expression {
  36. get { return _expression; }
  37. }
  38. public override string ToString() {
  39. return base.ToString() + ":" + _name;
  40. }
  41. internal Argument GetArgumentInfo() {
  42. if (_name == null) {
  43. return Argument.Simple;
  44. } else if (_name == "*") {
  45. return new Argument(ArgumentType.List);
  46. } else if (_name == "**") {
  47. return new Argument(ArgumentType.Dictionary);
  48. } else {
  49. return new Argument(_name);
  50. }
  51. }
  52. public override void Walk(PythonWalker walker) {
  53. if (walker.Walk(this)) {
  54. if (_expression != null) {
  55. _expression.Walk(walker);
  56. }
  57. }
  58. walker.PostWalk(this);
  59. }
  60. }
  61. }