scope.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * EliasDB
  3. *
  4. * Copyright 2016 Matthias Ladkau. All rights reserved.
  5. *
  6. * This Source Code Form is subject to the terms of the Mozilla Public
  7. * License, v. 2.0. If a copy of the MPL was not distributed with this
  8. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. */
  10. /*
  11. Package interpreter contains the ECAL interpreter.
  12. */
  13. package interpreter
  14. import (
  15. "sync"
  16. "devt.de/krotik/common/lang/ecal/parser"
  17. )
  18. // TODO: Scope with value buckets which can be read only - auto provide access to parent scopes
  19. /*
  20. DataBucket models a storage bucket for data.
  21. */
  22. type DataBucket struct {
  23. data interface{} // Data of this bucket
  24. canWrite bool // Flag if data can be written to this bucket
  25. }
  26. /*
  27. Scope models an ECAL scope. It is used to store variable data.
  28. */
  29. type Scope struct {
  30. name string // Name of the scope
  31. parent *Scope // Parent scope
  32. storage map[string]*DataBucket // Storage for variables
  33. lock sync.RWMutex // Lock for this scope
  34. }
  35. /*
  36. NewChild creates a new child scope.
  37. */
  38. func (s *Scope) NewChild(name string) parser.VarsScope {
  39. return nil
  40. }
  41. /*
  42. SetValue sets a new value for a variable.
  43. */
  44. func (s *Scope) SetValue(varName string, varValue interface{}) error {
  45. return nil
  46. }
  47. /*
  48. GetValue gets the current value of a variable.
  49. */
  50. func (s *Scope) GetValue(varName string) (interface{}, bool, error) {
  51. return nil, false, nil
  52. }
  53. /*
  54. String returns a string representation of this variable scope.
  55. */
  56. func (s *Scope) String() string {
  57. return ""
  58. }