@@ -356,11 +356,6 @@ class Hook {
356356
357357 addLocation ( location ) {
358358 this . locations . push ( location ) ;
359- const self = this ;
360- location . then ( ( l ) => {
361- console . log ( self . constructor . name )
362- console . log ( l )
363- } ) ;
364359 }
365360
366361 async getLocations ( ) {
@@ -726,24 +721,24 @@ class TracingHandler {
726721 * ********************** update ********************************
727722 * **************************************************************
728723 */
729- static memberUpdated ( obj , prop ) {
724+ static memberUpdated ( obj , prop , location ) {
730725 const hook = SourceCodeHook . get ( obj , prop ) ;
731726 if ( ! hook ) return ;
732- hook . addLocation ( TracingHandler . findRegistrationLocation ( ) ) ;
727+ hook . addLocation ( location || TracingHandler . findRegistrationLocation ( ) ) ;
733728 hook . notifyDependencies ( ) ;
734729 }
735730
736- static globalUpdated ( globalName ) {
731+ static globalUpdated ( globalName , location ) {
737732 const hook = SourceCodeHook . get ( globalRef , globalName ) ;
738733 if ( ! hook ) return ;
739- hook . addLocation ( TracingHandler . findRegistrationLocation ( ) ) ;
734+ hook . addLocation ( location || TracingHandler . findRegistrationLocation ( ) ) ;
740735 hook . notifyDependencies ( ) ;
741736 }
742737
743- static localUpdated ( scope , varName ) {
738+ static localUpdated ( scope , varName , location ) {
744739 const hook = SourceCodeHook . get ( scope , varName ) ;
745740 if ( ! hook ) return ;
746- hook . addLocation ( TracingHandler . findRegistrationLocation ( ) ) ;
741+ hook . addLocation ( location || TracingHandler . findRegistrationLocation ( ) ) ;
747742 hook . notifyDependencies ( ) ;
748743 }
749744
@@ -754,7 +749,12 @@ class TracingHandler {
754749
755750 for ( let frame of frames . slice ( ) ) {
756751 if ( ! frame . file . includes ( "active-expression" ) ) {
757- return frame . getSourceLoc ( ) ;
752+ const loc = await frame . getSourceLoc ( ) ;
753+ return {
754+ start : { line : loc . line , column : loc . column } ,
755+ end : { line : loc . line , column : loc . column } ,
756+ file : loc . source ,
757+ }
758758 }
759759 }
760760 return undefined ;
@@ -805,87 +805,87 @@ export function getAndCallMember(obj, prop, args = []) {
805805 return result ;
806806}
807807
808- export function setMember ( obj , prop , val ) {
808+ export function setMember ( obj , prop , val , location ) {
809809 const result = obj [ prop ] = val ;
810- TracingHandler . memberUpdated ( obj , prop ) ;
810+ TracingHandler . memberUpdated ( obj , prop , location ) ;
811811 return result ;
812812}
813813
814- export function setMemberAddition ( obj , prop , val ) {
814+ export function setMemberAddition ( obj , prop , val , location ) {
815815 const result = obj [ prop ] += val ;
816- TracingHandler . memberUpdated ( obj , prop ) ;
816+ TracingHandler . memberUpdated ( obj , prop , location ) ;
817817 return result ;
818818}
819819
820- export function setMemberSubtraction ( obj , prop , val ) {
820+ export function setMemberSubtraction ( obj , prop , val , location ) {
821821 const result = obj [ prop ] -= val ;
822- TracingHandler . memberUpdated ( obj , prop ) ;
822+ TracingHandler . memberUpdated ( obj , prop , location ) ;
823823 return result ;
824824}
825825
826- export function setMemberMultiplication ( obj , prop , val ) {
826+ export function setMemberMultiplication ( obj , prop , val , location ) {
827827 const result = obj [ prop ] *= val ;
828- TracingHandler . memberUpdated ( obj , prop ) ;
828+ TracingHandler . memberUpdated ( obj , prop , location ) ;
829829 return result ;
830830}
831831
832- export function setMemberDivision ( obj , prop , val ) {
832+ export function setMemberDivision ( obj , prop , val , location ) {
833833 const result = obj [ prop ] /= val ;
834- TracingHandler . memberUpdated ( obj , prop ) ;
834+ TracingHandler . memberUpdated ( obj , prop , location ) ;
835835 return result ;
836836}
837837
838- export function setMemberRemainder ( obj , prop , val ) {
838+ export function setMemberRemainder ( obj , prop , val , location ) {
839839 const result = obj [ prop ] %= val ;
840- TracingHandler . memberUpdated ( obj , prop ) ;
840+ TracingHandler . memberUpdated ( obj , prop , location ) ;
841841 return result ;
842842}
843843
844- export function setMemberExponentiation ( obj , prop , val ) {
844+ export function setMemberExponentiation ( obj , prop , val , location ) {
845845 const result = obj [ prop ] **= val ;
846- TracingHandler . memberUpdated ( obj , prop ) ;
846+ TracingHandler . memberUpdated ( obj , prop , location ) ;
847847 return result ;
848848}
849849
850- export function setMemberLeftShift ( obj , prop , val ) {
850+ export function setMemberLeftShift ( obj , prop , val , location ) {
851851 const result = obj [ prop ] <<= val ;
852- TracingHandler . memberUpdated ( obj , prop ) ;
852+ TracingHandler . memberUpdated ( obj , prop , location ) ;
853853 return result ;
854854}
855855
856- export function setMemberRightShift ( obj , prop , val ) {
856+ export function setMemberRightShift ( obj , prop , val , location ) {
857857 const result = obj [ prop ] >>= val ;
858- TracingHandler . memberUpdated ( obj , prop ) ;
858+ TracingHandler . memberUpdated ( obj , prop , location ) ;
859859 return result ;
860860}
861861
862- export function setMemberUnsignedRightShift ( obj , prop , val ) {
862+ export function setMemberUnsignedRightShift ( obj , prop , val , location ) {
863863 const result = obj [ prop ] >>>= val ;
864- TracingHandler . memberUpdated ( obj , prop ) ;
864+ TracingHandler . memberUpdated ( obj , prop , location ) ;
865865 return result ;
866866}
867867
868- export function setMemberBitwiseAND ( obj , prop , val ) {
868+ export function setMemberBitwiseAND ( obj , prop , val , location ) {
869869 const result = obj [ prop ] &= val ;
870- TracingHandler . memberUpdated ( obj , prop ) ;
870+ TracingHandler . memberUpdated ( obj , prop , location ) ;
871871 return result ;
872872}
873873
874- export function setMemberBitwiseXOR ( obj , prop , val ) {
874+ export function setMemberBitwiseXOR ( obj , prop , val , location ) {
875875 const result = obj [ prop ] ^= val ;
876- TracingHandler . memberUpdated ( obj , prop ) ;
876+ TracingHandler . memberUpdated ( obj , prop , location ) ;
877877 return result ;
878878}
879879
880- export function setMemberBitwiseOR ( obj , prop , val ) {
880+ export function setMemberBitwiseOR ( obj , prop , val , location ) {
881881 const result = obj [ prop ] |= val ;
882- TracingHandler . memberUpdated ( obj , prop ) ;
882+ TracingHandler . memberUpdated ( obj , prop , location ) ;
883883 return result ;
884884}
885885
886- export function deleteMember ( obj , prop ) {
886+ export function deleteMember ( obj , prop , location ) {
887887 const result = delete obj [ prop ] ;
888- TracingHandler . memberUpdated ( obj , prop ) ;
888+ TracingHandler . memberUpdated ( obj , prop , location ) ;
889889 return result ;
890890}
891891
@@ -896,9 +896,9 @@ export function getLocal(scope, varName, value) {
896896 }
897897}
898898
899- export function setLocal ( scope , varName , value ) {
899+ export function setLocal ( scope , varName , value , location ) {
900900 scope [ varName ] = value ;
901- TracingHandler . localUpdated ( scope , varName ) ;
901+ TracingHandler . localUpdated ( scope , varName , location ) ;
902902}
903903
904904export function getGlobal ( globalName ) {
@@ -914,7 +914,7 @@ export async function getDependencyTriplesForFile(url) {
914914 for ( const dependency of HooksToDependencies . getDepsForHook ( hook ) ) {
915915 for ( const ae of DependenciesToAExprs . getAExprsForDep ( dependency ) ) {
916916 const location = ae . meta ( ) . get ( "location" ) . file ;
917- if ( location . includes ( url ) || locations . some ( loc => loc && loc . source . includes ( url ) ) ) {
917+ if ( location . includes ( url ) || locations . some ( loc => loc && loc . file . includes ( url ) ) ) {
918918 result . push ( { hook, dependency, ae } ) ;
919919 }
920920 }
@@ -931,8 +931,8 @@ export async function getAETriplesForFile(url) {
931931 return DependenciesToAExprs . getAETriplesForFile ( url ) ;
932932}
933933
934- export function setGlobal ( globalName ) {
935- TracingHandler . globalUpdated ( globalName ) ;
934+ export function setGlobal ( globalName , location ) {
935+ TracingHandler . globalUpdated ( globalName , location ) ;
936936}
937937
938938export default aexpr ;
0 commit comments