Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Ink / InkLibs / InkCompiler / ParsedHierarchy / ConstantDeclaration.cs
  1. //using System.Collections.Generic;
  2. namespace Ink.Parsed
  3. {
  4. public class ConstantDeclaration : Parsed.Object
  5. {
  6. public string constantName
  7. {
  8. get { return constantIdentifier?.name; }
  9. }
  10. public Identifier constantIdentifier { get; protected set; }
  11. public Expression expression { get; protected set; }
  12. public ConstantDeclaration (Identifier name, Expression assignedExpression)
  13. {
  14. this.constantIdentifier = name;
  15. // Defensive programming in case parsing of assignedExpression failed
  16. if( assignedExpression )
  17. this.expression = AddContent(assignedExpression);
  18. }
  19. public override Runtime.Object GenerateRuntimeObject ()
  20. {
  21. // Global declarations don't generate actual procedural
  22. // runtime objects, but instead add a global variable to the story itself.
  23. // The story then initialises them all in one go at the start of the game.
  24. return null;
  25. }
  26. public override void ResolveReferences (Story context)
  27. {
  28. base.ResolveReferences (context);
  29. context.CheckForNamingCollisions (this, constantIdentifier, Story.SymbolType.Var);
  30. }
  31. public override string typeName {
  32. get {
  33. return "Constant";
  34. }
  35. }
  36. }
  37. }