PageRenderTime 49ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/src/aerys/minko/render/shader/compiler/graph/nodes/leaf/BindableConstant.as

https://bitbucket.org/HopeSky/mars_nd2d
ActionScript | 59 lines | 41 code | 13 blank | 5 comment | 5 complexity | cf2c6de87c8c34d7036b479680c46195 MD5 | raw file
  1. package aerys.minko.render.shader.compiler.graph.nodes.leaf
  2. {
  3. import aerys.minko.render.shader.compiler.CRC32;
  4. import aerys.minko.render.shader.compiler.graph.nodes.AbstractNode;
  5. /**
  6. * @private
  7. * @author Romain Gilliotte
  8. *
  9. */
  10. public class BindableConstant extends AbstractNode
  11. {
  12. public static const COMPUTABLE_CONSTANT_PREFIX : String = 'computableConstant';
  13. private var _bindingName : String;
  14. private var _size : uint;
  15. public function get bindingName() : String
  16. {
  17. return _bindingName;
  18. }
  19. public function BindableConstant(bindingName : String, size : uint)
  20. {
  21. super(new <AbstractNode>[], new <uint>[]);
  22. if (size == 0)
  23. throw new Error('Cannot create a zero-sized parameter');
  24. if (size > 4 && size % 4 != 0)
  25. throw new Error('Size of a parameter must be either less or equal than 4, or a multiple of 4');
  26. _size = size;
  27. _bindingName = bindingName;
  28. }
  29. override protected function computeHash() : uint
  30. {
  31. return CRC32.computeForString('BindableConstant_' + _bindingName + '_' + _size);
  32. }
  33. override protected function computeSize() : uint
  34. {
  35. return _size;
  36. }
  37. override public function toString() : String
  38. {
  39. return 'BindableConstant_' + bindingName + '_' + size;
  40. }
  41. override public function clone() : AbstractNode
  42. {
  43. return new BindableConstant(_bindingName, _size);
  44. }
  45. }
  46. }