@@ -478,9 +478,7 @@ contents =
478478 finalizer : finally -clause
479479
480480 \macro : ->
481- env = this
482-
483- compile -as -macro = (es -ast ) ->
481+ compile -as -macro = (es -ast ) ~>
484482
485483 # This hack around require makes loading macros from relative paths work.
486484 #
@@ -501,7 +499,7 @@ contents =
501499 root -require = main .require.bind main
502500
503501 let require = root -require
504- eval "(#{env. compile-to-js es-ast})"
502+ eval "(#{@ compile-to-js es-ast})"
505503
506504 switch &length
507505 | 1 =>
@@ -511,21 +509,21 @@ contents =
511509
512510 # Mask any macro of that name in the current scope
513511
514- import -compilerspace -macro env , form .value, null
512+ import -compilerspace -macro this , form .value, null
515513
516514 | otherwise
517515
518516 # Attempt to compile the argument, hopefully into an object,
519517 # define macros from its keys
520518
521- es -ast = env . compile form
519+ es -ast = @ compile form
522520
523521 result = compile -as -macro es -ast
524522
525523 switch typeof ! result
526524 | \Object =>
527525 for k , v of result
528- import -compilerspace -macro env , k , v
526+ import -compilerspace -macro this , k , v
529527 | \Null => fallthrough
530528 | \Undefined => # do nothing
531529 | otherwise =>
@@ -540,19 +538,19 @@ contents =
540538 name = name .value
541539 target -name = form .value
542540
543- alias -target -macro = env . find-macro target -name
541+ alias -target -macro = @ find -macro target -name
544542
545543 if not alias -target -macro
546544 throw Error "Macro alias target `#target-name` is not defined"
547545
548- import -compilerspace -macro env , name , alias -target -macro
546+ import -compilerspace -macro this , name , alias -target -macro
549547
550548 | form .type is \list
551549
552- userspace -macro = form |> env . compile |> compile -as -macro
550+ userspace -macro = form |> @ compile |> compile -as -macro
553551
554552 name .= value
555- import -compilerspace -macro env , name , userspace -macro
553+ import -compilerspace -macro this , name , userspace -macro
556554
557555 | otherwise =>
558556 throw Error "Bad number of arguments to macro constructor \
@@ -567,23 +565,24 @@ contents =
567565 # means we have to resolve lists which first atom is `unquote` or
568566 # `unquote-splicing` into either an array of values or an identifier to
569567 # an array of values.
570- qq -body = (env , ast ) ->
571568
572- recurse -on = (ast -list ) ->
569+ qq -body = (ast ) ->
570+
571+ recurse -on = (ast -list ) ~>
573572 ast -list .values
574- |> map qq -body env , _
573+ |> map qq -body .bind this
575574 |> generate -concat
576575
577- unquote = - >
578- if arguments . length isnt 1
576+ unquote = ~ >
577+ if & length isnt 1
579578 throw Error "Expected 1 argument to unquote but got #{rest.length}"
580579
581580 # Unquoting should compile to just the thing separated with an array
582581 # wrapper.
583- [ env . compile it ]
582+ [ @ compile it ]
584583
585- unquote -splicing = - >
586- if arguments . length isnt 1
584+ unquote -splicing = ~ >
585+ if & length isnt 1
587586 throw Error "Expected 1 argument to unquoteSplicing but got
588587 #{rest.length}"
589588
@@ -592,8 +591,7 @@ contents =
592591
593592 type : \MemberExpression
594593 computed : false
595- object :
596- env .compile it
594+ object : @compile it
597595 property :
598596 type : \Identifier
599597 name : \values
@@ -604,19 +602,19 @@ contents =
604602 switch
605603 | not head ?
606604 # quote an empty list
607- [ quote .call env , {
605+ [ quote .call this , {
608606 type : \list
609607 values : []
610- location :"returned from macro"
608+ location : "returned from macro"
611609 } ]
612610 | head .type is \atom =>
613611 switch head .value
614- | \unquote => unquote .apply null rest
615- | \unquote -splicing => unquote -splicing .apply null rest
612+ | \unquote => unquote ... rest
613+ | \unquote -splicing => unquote -splicing ... rest
616614 | _ => [ recurse -on ast ]
617615 | _ => [ recurse -on ast ]
618616
619- | _ => [ quote .call env , ast ]
617+ | _ => [ quote .call this , ast ]
620618
621619 generate -concat = (concattable -things ) ->
622620
@@ -668,9 +666,6 @@ contents =
668666 arguments : it
669667 ]
670668 qq = (arg ) ->
671-
672- env = this
673-
674669 if &length > 1
675670 throw Error "Too many arguments to quasiquote (`); \
676671 expected 1, got #{&length}"
@@ -681,14 +676,14 @@ contents =
681676
682677 if first -arg .type is \atom and first -arg .value is \unquote
683678 rest = arg .values.slice 1 .0
684- env . compile rest
679+ @ compile rest
685680
686681 else
687682 arg .values
688- |> map qq -body env , _
683+ |> map qq -body .call this , _
689684 |> generate -concat
690685
691- else quote .call env , arg # act like regular quote
686+ else quote .call this , arg # act like regular quote
692687
693688module .exports =
694689 parent : null
0 commit comments