file author cxtom(cxtom2008 gmail import { EmitHint , isPropertyAccessExpression , isIdentifier , isCallExpression , CallExpression } from 'byots' ; import method from '../utilities/method' ; function log ( node , { emitExpression , writePunctuation , writeSpace } ) { writePunctuation ( 'echo' ) ; writeSpace ( ) ; node . arguments . forEach ( ( elememt , index ) => { emitExpression ( elememt ) ; if ( index < node . arguments . length - 1 ) { writePunctuation ( ',' ) ; writeSpace ( ) ; } } ) ; } const methods = { log , info : method ( 'var_dump' , { self : false } ) , error : log , dir ( node , { emitExpression , writePunctuation } ) { writePunctuation ( 'echo "<script>console.log(" . json_encode(' ) ; emitExpression ( node . arguments [ 0 ] ) ; writePunctuation ( ') . ");</script>"' ) ; } } ; export default { emit ( hint , node , { helpers , helperNamespace } ) { const expNode = node . expression ; let func ; if ( hint === EmitHint . Expression && isCallExpression ( node ) && isPropertyAccessExpression ( expNode ) && isIdentifier ( expNode . expression ) && expNode . expression . escapedText === 'console' && ( func = methods [ helpers . getTextOfNode ( expNode . name ) ] ) ) { return func ( node , helpers , { helperNamespace } ) ; } return false ; } } ;