@@ -131,6 +131,8 @@ class ExpressionVisitor {
131131 private helper : VisitorHelper ,
132132 private expressionNode : ts . Expression ,
133133 private stubbedFunctionName ?: string ,
134+ private className ?: ts . Identifier ,
135+ private methodNode ?: ts . MethodDeclaration ,
134136 ) { }
135137
136138 public result ( ) : ts . Expression {
@@ -162,16 +164,20 @@ class ExpressionVisitor {
162164 let infoArg = info
163165 if ( isCallingEmit ( stubbedFunctionName ) ) {
164166 infoArg = this . helper . resolveTypeParameters ( updatedNode ) . map ( getGenericTypeInfo ) [ 0 ]
165- }
166- if ( isCallingDecodeArc4 ( stubbedFunctionName ) ) {
167+ } else if ( isCallingDecodeArc4 ( stubbedFunctionName ) ) {
167168 const targetType = ptypes . ptypeToArc4EncodedType ( type , this . helper . sourceLocation ( node ) )
168169 const targetTypeInfo = getGenericTypeInfo ( targetType )
169170 infoArg = targetTypeInfo
171+ } else if ( isCallingDecoratorMethod ( stubbedFunctionName ) ) {
172+ this . helper . additionalStatements . push ( nodeFactory . captureMethodConfig ( this . className ! , this . methodNode ! , updatedNode ) )
170173 }
174+
171175 updatedNode = stubbedFunctionName
172176 ? isCallingMethodSelector ( stubbedFunctionName )
173177 ? nodeFactory . callMethodSelectorFunction ( updatedNode )
174- : nodeFactory . callStubbedFunction ( stubbedFunctionName , updatedNode , infoArg )
178+ : isCallingDecoratorMethod ( stubbedFunctionName )
179+ ? updatedNode
180+ : nodeFactory . callStubbedFunction ( stubbedFunctionName , updatedNode , infoArg )
175181 : updatedNode
176182 }
177183 return needsToCaptureTypeInfo
@@ -208,7 +214,8 @@ class FunctionOrMethodVisitor {
208214 constructor (
209215 protected context : ts . TransformationContext ,
210216 protected helper : VisitorHelper ,
211- private isFunction ?: boolean ,
217+ protected className ?: ts . Identifier ,
218+ protected methodNode ?: ts . MethodDeclaration ,
212219 ) { }
213220 protected visit = ( node : ts . Node ) : ts . Node => {
214221 return ts . visitEachChild ( this . updateNode ( node ) , this . visit , this . context )
@@ -269,7 +276,7 @@ class FunctionOrMethodVisitor {
269276 if ( ts . isCallExpression ( node ) ) {
270277 const stubbedFunctionName = tryGetStubbedFunctionName ( node , this . helper )
271278 if ( stubbedFunctionName ) {
272- return new ExpressionVisitor ( this . context , this . helper , node , stubbedFunctionName ) . result ( )
279+ return new ExpressionVisitor ( this . context , this . helper , node , stubbedFunctionName , this . className , this . methodNode ) . result ( )
273280 }
274281 }
275282
@@ -283,7 +290,7 @@ class FunctionLikeDecVisitor extends FunctionOrMethodVisitor {
283290 helper : VisitorHelper ,
284291 private funcNode : ts . SignatureDeclaration ,
285292 ) {
286- super ( context , helper , true )
293+ super ( context , helper )
287294 }
288295
289296 public result ( ) : ts . SignatureDeclaration {
@@ -294,9 +301,10 @@ class MethodDecVisitor extends FunctionOrMethodVisitor {
294301 constructor (
295302 context : ts . TransformationContext ,
296303 helper : VisitorHelper ,
297- private methodNode : ts . MethodDeclaration ,
304+ methodNode : ts . MethodDeclaration ,
305+ className : ts . Identifier | undefined ,
298306 ) {
299- super ( context , helper )
307+ super ( context , helper , className , methodNode )
300308 }
301309
302310 public result ( ) : ts . MethodDeclaration {
@@ -330,7 +338,7 @@ class ClassVisitor {
330338 }
331339 }
332340
333- return new MethodDecVisitor ( this . context , this . helper , node ) . result ( )
341+ return new MethodDecVisitor ( this . context , this . helper , node , this . classDec . name ) . result ( )
334342 }
335343
336344 if ( ts . isCallExpression ( node ) ) {
@@ -421,10 +429,11 @@ const tryGetStubbedFunctionName = (node: ts.CallExpression, helper: VisitorHelpe
421429 if ( sourceFileName && ! algotsModulePaths . some ( ( s ) => sourceFileName . includes ( s ) ) ) return undefined
422430 }
423431 const functionName = functionSymbol ?. getName ( ) ?? identityExpression . text
424- const stubbedFunctionNames = [ 'interpretAsArc4' , 'decodeArc4' , 'encodeArc4' , 'emit' , 'methodSelector' ]
432+ const stubbedFunctionNames = [ 'interpretAsArc4' , 'decodeArc4' , 'encodeArc4' , 'emit' , 'methodSelector' , 'abimethod' , 'baremethod' ]
425433 return stubbedFunctionNames . includes ( functionName ) ? functionName : undefined
426434}
427435
428436const isCallingDecodeArc4 = ( functionName : string | undefined ) : boolean => [ 'decodeArc4' , 'encodeArc4' ] . includes ( functionName ?? '' )
429437const isCallingEmit = ( functionName : string | undefined ) : boolean => 'emit' === ( functionName ?? '' )
430438const isCallingMethodSelector = ( functionName : string | undefined ) : boolean => 'methodSelector' === ( functionName ?? '' )
439+ const isCallingDecoratorMethod = ( functionName : string | undefined ) : boolean => [ 'abimethod' , 'baremethod' ] . includes ( functionName ?? '' )
0 commit comments