prebirth: Always process identifiers (remove global distinction)

* build-aux/bootstrap/prebirth.js
  (_cdfn): Remove second argument to `#_idFromName'.
  (_idFromName): Remove second parameter `global'.  Identify and echo
    integers.  Remove distinction between global and non-global
    identifiers---process everything.
master
Mike Gerwitz 2017-09-21 02:19:38 -04:00
parent 3310241a94
commit ea7425dc6d
Signed by: mikegerwitz
GPG Key ID: 8C917B7F5DC51BA2
1 changed files with 8 additions and 6 deletions

View File

@ -355,7 +355,7 @@ class Compiler
// e.g. (define (foo ...) body)
const [ , [ { value: name }, ...params ], ...body ] = t;
const id = this._idFromName( name, true );
const id = this._idFromName( name );
const paramjs = this._paramsToEs( params );
const bodyjs = this._bodyToEs( body );
@ -391,13 +391,16 @@ class Compiler
* be reliably distinguished from one-another. Remember: this is
* temporary code.
*
* @param {string} name source name
* @param {boolean} global whether identifier should be globally unique
* @param {string} name source name
*
* @return {string} ES-friendly identifier
*/
_idFromName( name, global )
_idFromName( name )
{
if ( /^\d+$/.test( name ) ) {
return name;
}
// just some common ones; will fall back to `$' below
const conv = {
'-': '$_$',
@ -421,8 +424,7 @@ class Compiler
throw SyntaxError( "Missing identifier name" );
}
return ( global ? '$$' : '' ) +
name.replace( /[^a-zA-Z0-9_]/g, c => conv[ c ] || '$' );
return '$$' + name.replace( /[^a-zA-Z0-9_]/g, c => conv[ c ] || '$' );
}