{"version":3,"sources":["https://lively-kernel.org/lively4/lively4-drawio/src/client/reactive/active-expression-rewriting/active-expression-rewriting.js"],"names":["BaseActiveExpression","Stack","CompositeKey","InjectiveMap","BidirectionalMultiMap","using","isFunction","expressionAnalysisMode","window","__expressionAnalysisMode__","analysisModeManager","__enter__","__exit__","top","ExpressionAnalysis","recalculateDependencies","aexpr","disconnectAllFor","check","withElement","getCurrentValue","Dependency","getOrCreateFor","context","identifier","type","key","for","getOrCreateRightFor","constructor","isTracked","updateTracking","hasAExprsForDep","untrack","track","getContextAndIdentifier","value","undefined","associate","dataStructure","Array","Set","Map","dataHook","getOrCreate","forStructure","isGlobalDependency","wrappingHook","getOrCreateForProperty","disconnectAllForDependency","compKey","getLeftFor","keysFor","notifyAExprs","aexprs","getAExprsForDep","checkAndNotifyAExprs","isMemberDependency","isGlobal","isLocalDependency","object","self","getAsDependencyDescription","property","name","scope","Error","DependenciesToAExprs","_depsToAExprs","dep","disconnectAllForAExpr","deps","getDepsForAExpr","removeAllLeftFor","forEach","from","getRightsFor","getLeftsFor","length","hasDepsForAExpr","clear","getAllLeft","HooksToDependencies","_hooksToDeps","hook","remove","getDepsForHook","getHooksForDep","hasDepsForHook","hasHooksForDep","ContextAndIdentifierCompositeKey","CompositeKeyToDependencies","CompositeKeyToSourceCodeHook","DataStructureHookByDataStructure","WeakMap","PropertyWrappingHookByProperty","Hook","installed","notifyDependencies","SourceCodeHook","install","uninstall","DataStructureHook","getPrototypeDescriptors","obj","proto","prototype","descriptors","Object","getOwnPropertyDescriptors","entries","map","desc","wrapProperty","descriptor","after","defineProperty","assign","args","apply","call","monitorProperties","prototypeDescriptors","filter","addDescriptor","__compareAExprResults__","console","warn","PropertyWrappingHook","configurable","enumerable","getOwnPropertyDescriptor","get","set","result","aexprStack","RewritingActiveExpression","func","meta","strategy","new","target","addToRegistry","dispose","supportsDependencies","dependencies","DependencyAPI","sharedDependenciesWith","otherAExpr","ownDependencies","all","otherDependencies","own","shared","other","computeDiff","_aexpr","getDependencies","locals","dependency","members","globals","globalRef","global","DependencyManager","currentAExpr","checkAndNotify","associateMember","prop","associateGlobal","globalName","associateLocal","varName","TracingHandler","memberUpdated","globalUpdated","localUpdated","reset","traceMember","getMember","getAndCallMember","setMember","val","setMemberAddition","setMemberSubtraction","setMemberMultiplication","setMemberDivision","setMemberRemainder","setMemberExponentiation","setMemberLeftShift","setMemberRightShift","setMemberUnsignedRightShift","setMemberBitwiseAND","setMemberBitwiseXOR","setMemberBitwiseOR","deleteMember","getLocal","setLocal","getGlobal","setGlobal"],"mappings":";;;;;;AAMSA,0B,qBAAAA,oB;;AAEFC,W;;AACAC,kB;;AACAC,kB;;AACAC,2B;;AAMEC,W,UAAAA,K;AAAOC,gB,UAAAA,U;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhB;AACA,UAAIC,yBAAyB,KAA7B;;AACAC,aAAOC,0BAAP,GAAoC,KAApC;;AAEA,YAAMC,sBAAsB;AAC1BC,oBAAY;AACV,8HAAyB,IAAzB;AACAH,iBAAOC,0BAAP,8FAAoCF,sBAApC;AACD,SAJyB;AAK1BK,mBAAW;AACT,8HAAyB,CAAC,CAAC,sGAAWC,GAAX,EAA3B;AACAL,iBAAOC,0BAAP,8FAAoCF,sBAApC;AACD;AARyB,OAA5B;;AAUA,YAAMO,kBAAN,CAAyB;;AAEvB,eAAOC,uBAAP,CAA+BC,KAA/B,EAAsC;AACpC;AACA,uHAAkBC,gBAAlB,CAAmCD,KAAnC;AACA,eAAKE,KAAL,CAAWF,KAAX;AACD;;AAED,eAAOE,KAAP,CAAaF,KAAb,EAAoB;AAClB,2GAAM,4FAACN,mBAAD,CAAN,EAA6B,MAAM;AACjC;AACA,kHAAWS,WAAX,CAAuBH,KAAvB,EAA8B,MAAMA,MAAMI,eAAN,EAApC;AACD,WAHD;AAID;;AAbsB;;;AAiBzB,YAAMC,UAAN,CAAiB;AACf,eAAOC,cAAP,CAAsBC,OAAtB,EAA+BC,UAA/B,EAA2CC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M2G,OAAN,IAAiBxI,KAAjB;AACA,kHAAe4I,YAAf,CAA4B/G,KAA5B,EAAmC2G,OAAnC;AACD;;;;AAEM,eAAS0B,SAAT,CAAmB5B,UAAnB,EAA+B;AACpC,uGAAInK,sBAAJ,EAA4B;AAC1B,uHAAkBkK,eAAlB,CAAkCC,UAAlC;AACD;AACF;;;;AAEM,eAAS6B,SAAT,CAAmB7B,UAAnB,EAA+B;AACpC,kHAAeK,aAAf,CAA6BL,UAA7B;AACD;;;;oHAEc1J,K","file":"active-expression-rewriting.js","sourcesContent":["import 'lang';\n\n/*HTML \n<img src=\"https://lively-kernel.org/lively4/lively4-core/media/lively4_logo_smooth_100.png\"></img>'s Implementation of AExprs\nHTML*/\n\nimport { BaseActiveExpression } from 'active-expression';\n\nimport Stack from 'src/client/reactive/utils/stack.js';\nimport CompositeKey from './composite-key.js';\nimport InjectiveMap from './injective-map.js';\nimport BidirectionalMultiMap from './bidirectional-multi-map.js';\n/*HTML <editor-widget-location-info></editor-widget-location-info> HTML*/\n/*HTML <codemirror-playground></codemirror-playground> HTML*/\n\n/*HTML <span style=\"color: red\">hello</span> HTML*/\n\nimport { using, isFunction } from 'utils';\n\n/*MD # Dependency Analysis MD*/\nlet expressionAnalysisMode = false;\nwindow.__expressionAnalysisMode__ = false;\n\nconst analysisModeManager = {\n  __enter__() {\n    expressionAnalysisMode = true;\n    window.__expressionAnalysisMode__ = expressionAnalysisMode;\n  },\n  __exit__() {\n    expressionAnalysisMode = !!aexprStack.top();\n    window.__expressionAnalysisMode__ = expressionAnalysisMode;\n  }\n}\nclass ExpressionAnalysis {\n  \n  static recalculateDependencies(aexpr) {\n    // #TODO: compute diff of Dependencies\n    DependencyManager.disconnectAllFor(aexpr);\n    this.check(aexpr);\n  }\n  \n  static check(aexpr) {\n    using([analysisModeManager], () => {\n      // Do the function execution in ExpressionAnalysisMode\n      aexprStack.withElement(aexpr, () => aexpr.getCurrentValue());\n    });\n  }\n\n}\n\nclass Dependency {\n  static getOrCreateFor(context, identifier, type) {\n    const key = ContextAndIdentifierCompositeKey.for(context, identifier);\n    return CompositeKeyToDependencies.getOrCreateRightFor(key, () => new Dependency(type));\n  }\n\n  constructor(type) {\n    this.type = type;\n    \n    this.isTracked = false;\n  }\n\n  updateTracking() {\n    if (this.isTracked === DependenciesToAExprs.hasAExprsForDep(this)) { return; }\n    if (this.isTracked) {\n      this.untrack();\n    } else {\n      this.track();\n    }\n  }\n\n  track() {\n    this.isTracked = true;\n\n    const [context, identifier] = this.getContextAndIdentifier();\n    const value = context !== undefined ? context[identifier] : undefined;\n\n    /*HTML Source Code Hook HTML*/\n    // always employ the source code hook\n    HooksToDependencies.associate(SourceCodeHook.getOrCreateFor(context, identifier), this);\n\n    /*HTML Data Structure Hook HTML*/\n    var dataStructure;\n    if (this.type === 'member') {\n      dataStructure = context;\n    } else if(this.type === 'local') {\n      dataStructure = value;\n    }\n    if (dataStructure instanceof Array || dataStructure instanceof Set || dataStructure instanceof Map) {\n      const dataHook = DataStructureHookByDataStructure.getOrCreate(dataStructure, dataStructure => DataStructureHook.forStructure(dataStructure));\n      HooksToDependencies.associate(dataHook, this);\n    }\n\n    /*HTML <span style=\"font-weight: bold;\">Wrapping Hook</span>: only for <span style=\"color: green; font-weight: bold;\">\"that\"</span> HTML*/\n    if (this.isGlobalDependency() && identifier === 'that') {\n      const wrappingHook = PropertyWrappingHook.getOrCreateForProperty(identifier);\n      HooksToDependencies.associate(wrappingHook, this);\n    }\n\n  }\n  untrack() {\n    this.isTracked = false;\n    HooksToDependencies.disconnectAllForDependency(this);\n  }\n  getContextAndIdentifier() {\n    const compKey = CompositeKeyToDependencies.getLeftFor(this);\n    const [context, identifier] = ContextAndIdentifierCompositeKey.keysFor(compKey);\n    return [context, identifier];\n  }\n\n  notifyAExprs() {\n    const aexprs = DependenciesToAExprs.getAExprsForDep(this);\n    DependencyManager.checkAndNotifyAExprs(aexprs);\n  }\n  \n  isMemberDependency() {\n    return this.type === 'member' && !this.isGlobal();\n  }\n  isGlobalDependency() {\n    return this.type === 'member' && this.isGlobal();\n  }\n  isLocalDependency() {\n    return this.type === 'local';\n  }\n  isGlobal() {\n    const compKey = CompositeKeyToDependencies.getLeftFor(this);\n    if (!compKey) {\n      return false;\n    }\n    const [object] = ContextAndIdentifierCompositeKey.keysFor(compKey);\n    return object === self;\n  }\n\n  getAsDependencyDescription() {\n    const [context, identifier] = this.getContextAndIdentifier();\n    \n    if (this.isMemberDependency()) {\n      return {\n        object: context,\n        property: identifier,\n        value: context !== undefined ? context[identifier] : undefined\n      };\n    } else if (this.isGlobalDependency()) {\n      return {\n        name: identifier,\n        value: context[identifier]\n      };\n    } else if (this.isLocalDependency()) {\n      return {\n        scope: context,\n        name: identifier,\n        value: context !== undefined ? context[identifier] : undefined\n      };\n    } else {\n      throw new Error('Dependency is neighter local, member, nor global.');\n    }\n  }\n\n}\n\nconst DependenciesToAExprs = {\n  _depsToAExprs: new BidirectionalMultiMap(),\n\n  associate(dep, aexpr) {\n    this._depsToAExprs.associate(dep, aexpr);\n    dep.updateTracking();\n  },\n\n  disconnectAllForAExpr(aexpr) {\n    const deps = this.getDepsForAExpr(aexpr);\n    this._depsToAExprs.removeAllLeftFor(aexpr);\n    deps.forEach(dep => dep.updateTracking());\n  },\n\n  getAExprsForDep(dep) {\n    return Array.from(this._depsToAExprs.getRightsFor(dep));\n  },\n  getDepsForAExpr(aexpr) {\n    return Array.from(this._depsToAExprs.getLeftsFor(aexpr));\n  },\n\n  hasAExprsForDep(dep) {\n    return this.getAExprsForDep(dep).length >= 1;\n  },\n  hasDepsForAExpr(aexpr) {\n    return this.getDepsForAExpr(aexpr).length >= 1;\n  },\n  \n  /*\n   * Removes all associations.\n   */\n  clear() {\n    this._depsToAExprs.clear();\n    this._depsToAExprs.getAllLeft()\n      .forEach(dep => dep.updateTracking());\n  }\n};\n\nconst HooksToDependencies = {\n  _hooksToDeps: new BidirectionalMultiMap(),\n  \n  associate(hook, dep) {\n    this._hooksToDeps.associate(hook, dep);\n  },\n  remove(hook, dep) {\n    this._hooksToDeps.remove(hook, dep);\n  },\n  \n  disconnectAllForDependency(dep) {\n    this._hooksToDeps.removeAllLeftFor(dep);\n  },\n  \n  getDepsForHook(hook) {\n    return Array.from(this._hooksToDeps.getRightsFor(hook));\n  },\n  getHooksForDep(dep) {\n    return Array.from(this._hooksToDeps.getLeftsFor(dep));\n  },\n  \n  hasDepsForHook(hook) {\n    return this.getDepsForHook(hook).length >= 1;\n  },\n  hasHooksForDep(dep) {\n    return this.getHooksForDep(dep).length >= 1;\n  },\n  \n  /*\n   * Removes all associations.\n   */\n  clear() {\n    this._hooksToDeps.clear();\n  }\n};\n\n// 1. (obj, prop) or (scope, name) -> ContextAndIdentifierCompositeKey\n// - given via ContextAndIdentifierCompositeKey\nconst ContextAndIdentifierCompositeKey = new CompositeKey();\n\n// 2.1. ContextAndIdentifierCompositeKey 1<->1 Dependency\n// - CompositeKeyToDependencies\nconst CompositeKeyToDependencies = new InjectiveMap();\n// 2.2. Dependency *<->* AExpr\n// - DependenciesToAExprs\n\n/** Source Code Hooks */\n// 3.1. ContextAndIdentifierCompositeKey 1<->1 SourceCodeHook\n// - CompositeKeyToSourceCodeHook\nconst CompositeKeyToSourceCodeHook = new InjectiveMap();\n// 3.2. SourceCodeHook *<->* Dependency\n// - HooksToDependencies\n\n/** Data Structure Hooks */\n// 4.1 DataStructureHookByDataStructure\nconst DataStructureHookByDataStructure = new WeakMap(); // WeakMap<(Set/Array/Map), DataStructureHook>\n/** Wrapping Hooks */\n// 4.2 PropertyWrappingHookByProperty\nconst PropertyWrappingHookByProperty = new Map(); // Map<(String/Symbol), PropertyWrappingHook>\n\nclass Hook {\n  constructor() {\n    this.installed = false;\n  }\n  \n  notifyDependencies() {\n    HooksToDependencies.getDepsForHook(this).forEach(dep => dep.notifyAExprs())\n  }\n}\n\nclass SourceCodeHook extends Hook {\n  static getOrCreateFor(context, identifier) {\n    const compKey = ContextAndIdentifierCompositeKey.for(context, identifier);\n    return CompositeKeyToSourceCodeHook.getOrCreateRightFor(compKey, key => new SourceCodeHook());\n  }\n  \n  constructor(context, identifier) {\n    super();\n\n    this.context = context;\n    this.identifier = identifier;\n  }\n  \n  install() {}\n  uninstall() {}\n}\n\nclass DataStructureHook extends Hook {\n  static forStructure(dataStructure) {\n    const hook = new DataStructureHook();\n    \n    function getPrototypeDescriptors(obj) {\n      const proto = obj.constructor.prototype;\n\n      const descriptors = Object.getOwnPropertyDescriptors(proto);\n      return Object.entries(descriptors).map(([key, desc]) => (desc.key = key, desc))\n    }\n\n    function wrapProperty(obj, descriptor, after) {\n      Object.defineProperty(obj, descriptor.key, Object.assign({}, descriptor, {\n        value(...args) {\n          try {\n            return descriptor.value.apply(this, args);\n          } finally {\n            after.call(this, ...args)\n          }\n        }\n      }));\n    }\n\n    function monitorProperties(obj) {\n      const prototypeDescriptors = getPrototypeDescriptors(obj);\n      Object.entries(Object.getOwnPropertyDescriptors(obj)); // unused -> need for array\n\n      prototypeDescriptors\n        .filter(descriptor => descriptor.key !== 'constructor') // the property constructor needs to be a constructor if called (as in cloneDeep in lodash); We leave it out explicitly as the constructor does not change any state #TODO\n        .forEach(addDescriptor => {\n          // var addDescriptor = prototypeDescriptors.find(d => d.key === 'add')\n          if (addDescriptor.value) {\n            if (isFunction(addDescriptor.value)) {\n              wrapProperty(obj, addDescriptor, function() {\n                // #HACK #TODO we need an `withoutLayer` equivalent here\n                if (window.__compareAExprResults__) { return; }\n\n                this; // references the modified container\n                hook.notifyDependencies();\n              });\n            } else {\n              console.warn(`Property ${addDescriptor.key} has a value that is not a function, but ${addDescriptor.value}.`)\n            }\n          } else {\n            console.warn(`Property ${addDescriptor.key} has no value.`)\n          }\n        });\n    }\n\n    monitorProperties(dataStructure);\n    \n    // set.add = function add(...args) {\n    //   const result = Set.prototype.add.call(this, ...args);\n    //   hook.notifyDependencies();\n    //   return result;\n    // }\n    return hook;\n  }\n}\n\nclass PropertyWrappingHook extends Hook {\n  static getOrCreateForProperty(property) {\n    return PropertyWrappingHookByProperty.getOrCreate(property, () => new PropertyWrappingHook(property));\n  }\n  \n  constructor(property) {\n    super();\n\n    this.value = self[property];\n    const { configurable, enumerable } = Object.getOwnPropertyDescriptor(self, property);\n\n    // #TODO: keep old property accessors if present (otherwise, we do not interact with COP and ourselves, i.e. other property wrappers)\n    Object.defineProperty(self, property, {\n      configurable,\n      enumerable,\n      \n      get: () => this.value,\n      set: value => {\n        const result = this.value = value;\n        this.notifyDependencies();\n        return result;\n      }\n    });\n  }\n}\n\nconst aexprStack = new Stack();\n\nexport class RewritingActiveExpression extends BaseActiveExpression {\n  constructor(func, ...args) {\n    super(func, ...args);\n    this.meta({ strategy: 'Rewriting' });\n    ExpressionAnalysis.recalculateDependencies(this);\n\n    if (new.target === RewritingActiveExpression) {\n      this.addToRegistry();\n    }\n  }\n\n  dispose() {\n    super.dispose();\n    DependencyManager.disconnectAllFor(this);\n  }\n\n  supportsDependencies() {\n    return true;\n  }\n\n  dependencies() {\n    return new DependencyAPI(this);\n  }\n  \n  sharedDependenciesWith(otherAExpr) {\n    const ownDependencies = this.dependencies().all();\n    const otherDependencies = otherAExpr.dependencies().all();\n    const [own, shared, other] = ownDependencies.computeDiff(otherDependencies);\n    return shared;\n  }\n}\n\nclass DependencyAPI {\n  constructor(aexpr) {\n    this._aexpr = aexpr;\n  }\n  \n  getDependencies() {\n    return DependenciesToAExprs.getDepsForAExpr(this._aexpr);\n  }\n\n  all() {\n    return Array.from(this.getDependencies());\n  }\n  \n  locals() {\n    return this.getDependencies()\n      .filter(dependency => dependency.isLocalDependency())\n      .map(dependency => dependency.getAsDependencyDescription());\n  }\n\n  members() {\n    return this.getDependencies()\n      .filter(dependency => dependency.isMemberDependency())\n      .map(dependency => dependency.getAsDependencyDescription());\n  }\n\n  globals() {\n    return this.getDependencies()\n      .filter(dependency => dependency.isGlobalDependency())\n      .map(dependency => dependency.getAsDependencyDescription());\n  }\n}\n\nexport function aexpr(func, ...args) {\n  return new RewritingActiveExpression(func, ...args);\n}\n\nconst globalRef = typeof window !== \"undefined\" ? window : // browser tab\n  (typeof self !== \"undefined\" ? self : // web worker\n    global); // node.js\n\nclass DependencyManager {\n  static get currentAExpr() {\n    return aexprStack.top();\n  }\n  \n  // #TODO, #REFACTOR: extract into own method; remove from this class\n  static disconnectAllFor(aexpr) {\n    DependenciesToAExprs.disconnectAllForAExpr(aexpr);\n  }\n\n  // #TODO, #REFACTOR: extract into configurable dispatcher class\n  static checkAndNotifyAExprs(aexprs) {\n    aexprs.forEach(aexpr => {\n      ExpressionAnalysis.recalculateDependencies(aexpr);\n    });\n    aexprs.forEach(aexpr => aexpr.checkAndNotify());\n  }\n\n  /**\n   * **************************************************************\n   * ********************** associate *****************************\n   * **************************************************************\n   */\n  static associateMember(obj, prop) {\n    const dependency = Dependency.getOrCreateFor(obj, prop, 'member');\n    DependenciesToAExprs.associate(dependency, this.currentAExpr);\n  }\n\n  static associateGlobal(globalName) {\n    const dependency = Dependency.getOrCreateFor(globalRef, globalName, 'member');\n    DependenciesToAExprs.associate(dependency, this.currentAExpr);\n  }\n\n  static associateLocal(scope, varName) {\n    const dependency = Dependency.getOrCreateFor(scope, varName, 'local');\n    DependenciesToAExprs.associate(dependency, this.currentAExpr);\n  }\n\n}\n\nclass TracingHandler {\n\n  /**\n   * **************************************************************\n   * ********************** update ********************************\n   * **************************************************************\n   */\n  static memberUpdated(obj, prop) {\n    SourceCodeHook.getOrCreateFor(obj, prop).notifyDependencies();\n  }\n\n  static globalUpdated(globalName) {\n    SourceCodeHook.getOrCreateFor(globalRef, globalName).notifyDependencies();\n  }\n\n  static localUpdated(scope, varName) {\n    SourceCodeHook.getOrCreateFor(scope, varName).notifyDependencies();\n  }\n\n}\n\n/*\n * Disconnects all associations between active expressions and object properties\n * As a result no currently enable active expression will be notified again,\n * effectively removing them from the system.\n *\n * #TODO: Caution, this might break with some semantics, if we still have references to an aexpr!\n */\nexport function reset() {\n  ContextAndIdentifierCompositeKey.clear();\n\n  CompositeKeyToDependencies.clear();\n  DependenciesToAExprs.clear();\n\n  CompositeKeyToSourceCodeHook.clear();\n  HooksToDependencies.clear();\n}\n\n/*MD # Source Code Point Cuts MD*/\n/**\n * (C)RUD for member attributes\n */\nexport function traceMember(obj, prop) {\n  if (expressionAnalysisMode) {\n    DependencyManager.associateMember(obj, prop);\n  }\n}\n\nexport function getMember(obj, prop) {\n  if (expressionAnalysisMode) {\n    DependencyManager.associateMember(obj, prop);\n  }\n  const result = obj[prop];\n  return result;\n}\n\nexport function getAndCallMember(obj, prop, args = []) {\n  if (expressionAnalysisMode) {\n    DependencyManager.associateMember(obj, prop);\n  }\n  const result = obj[prop](...args);\n  return result;\n}\n\nexport function setMember(obj, prop, val) {\n  const result = obj[prop] = val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberAddition(obj, prop, val) {\n  const result = obj[prop] += val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberSubtraction(obj, prop, val) {\n  const result = obj[prop] -= val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberMultiplication(obj, prop, val) {\n  const result = obj[prop] *= val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberDivision(obj, prop, val) {\n  const result = obj[prop] /= val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberRemainder(obj, prop, val) {\n  const result = obj[prop] %= val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberExponentiation(obj, prop, val) {\n  const result = obj[prop] **= val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberLeftShift(obj, prop, val) {\n  const result = obj[prop] <<= val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberRightShift(obj, prop, val) {\n  const result = obj[prop] >>= val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberUnsignedRightShift(obj, prop, val) {\n  const result = obj[prop] >>>= val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberBitwiseAND(obj, prop, val) {\n  const result = obj[prop] &= val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberBitwiseXOR(obj, prop, val) {\n  const result = obj[prop] ^= val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function setMemberBitwiseOR(obj, prop, val) {\n  const result = obj[prop] |= val;\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function deleteMember(obj, prop) {\n  const result = delete obj[prop];\n  TracingHandler.memberUpdated(obj, prop);\n  return result;\n}\n\nexport function getLocal(scope, varName, value) {\n  if (expressionAnalysisMode) {\n    scope[varName] = value;\n    DependencyManager.associateLocal(scope, varName);\n  }\n}\n\nexport function setLocal(scope, varName, value) {\n  scope[varName] = value;\n  TracingHandler.localUpdated(scope, varName);\n}\n\nexport function getGlobal(globalName) {\n  if (expressionAnalysisMode) {\n    DependencyManager.associateGlobal(globalName);\n  }\n}\n\nexport function setGlobal(globalName) {\n  TracingHandler.globalUpdated(globalName);\n}\n\nexport default aexpr;\n"]}