Skip to content

Commit

Permalink
Update self-hosting to 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjohnson committed Oct 3, 2017
1 parent fe31d8c commit a20b583
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"lib"
],
"devDependencies": {
"@oigroup/babel-plugin-lightscript-self-host": "^2.0.0",
"@oigroup/lightscript-eslint-self-host": "^2.0.0",
"@oigroup/babel-plugin-lightscript-self-host": "^3.0.0",
"@oigroup/lightscript-eslint-self-host": "^3.0.0",
"babel-cli": "^6.24.1",
"babel-core": "^6.25.0",
"babel-helper-plugin-test-runner": "^6.24.1",
Expand Down
2 changes: 1 addition & 1 deletion src/classes.lsc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export ensureConstructor(classPath, constructorBodyPath, withSuper = true) ->
// methods at construction time.
export bindMethodsInConstructor(classPath, constructorPath, methodIds) ->
// `this.method = this.method.bind(this);`
assignments = [for elem methodId in methodIds:
assignments = [...for elem methodId in methodIds:
t.assertOneOf(methodId, ["Identifier", "Expression"])
isComputed = !is("Identifier", methodId)

Expand Down
12 changes: 6 additions & 6 deletions src/destructure.lsc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ HasLength(array, min, max, patternNode) ->
[
array
t.numericLiteral(min)~atNode(patternNode)
case max~looseNotEq(null): t.numericLiteral(max)~atNode(patternNode)
...if max~looseNotEq(null): t.numericLiteral(max)~atNode(patternNode)
]
)~atNode(patternNode)

Expand All @@ -50,7 +50,7 @@ export matchesArrayPattern(array, arrayPattern) ->

And([
array~HasLength(minLength, maxLength, arrayPattern)
for idx i, elem element in elements:
...for idx i, elem element in elements:
if element and element~isDestructuringPattern():
array~Bracket(i, element)~matchesDestructuringPattern(element)
])
Expand All @@ -77,7 +77,7 @@ export matchesObjectPattern(obj, objectPattern) ->
And([
// _hasProps(_obj, ...)
obj~HasProps(objectPattern, [
for elem property in properties:
...for elem property in properties:
if property~isa("ObjectProperty"):
{ key, value } = property
if (not value~isa("AssignmentPattern") and key~isa("Identifier")):
Expand All @@ -87,7 +87,7 @@ export matchesObjectPattern(obj, objectPattern) ->
// Conditions for nested patterns.
// Destructuring patterns get a nested match. Defaulted items get a nested match
// only if a default is not present.
for elem property in properties:
...for elem property in properties:
if property~isa("ObjectProperty"):
{ key, value } = property
match value:
Expand All @@ -111,7 +111,7 @@ maybeToRestructureExpression(node) ->

export toRestructureExpressionForArrayPattern(pattern) ->
t.arrayExpression(
[for elem element in pattern.elements:
[...for elem element in pattern.elements:
match element:
| ~isa("AssignmentPattern"): element.left~maybeToRestructureExpression()
| ~isa("RestElement"): t.spreadElement(element.argument)~atNode(element)
Expand All @@ -127,7 +127,7 @@ restructureObjAssignment(assign, defaultKey) ->

export toRestructureExpressionForObjectPattern(pattern) ->
t.objectExpression(
[for elem property in pattern.properties:
[...for elem property in pattern.properties:
match property:
| ~isa("RestProperty"):
t.spreadProperty(property.argument)~atNode(property)
Expand Down
2 changes: 1 addition & 1 deletion src/imports.lsc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export addImport(imports, importPath, name) ->
export insertImports(imports, path, useRequire = false) ->
loc = getCompilerState().firstLoc

stmts = [for key importPath, val importNames in imports:
stmts = [...for key importPath, val importNames in imports:
for elem name in importNames:
if useRequire:
// const [name] = require("[path]")
Expand Down
2 changes: 1 addition & 1 deletion src/index.lsc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ Lightscript(babel) ->

ObjectExpression(path): void ->
fatArrowKeys = [
for elem prop in path.node.properties:
...for elem prop in path.node.properties:
if prop~isa("Method") and prop.skinny == false:
prop.skinny = true // prevent recursion
prop.key
Expand Down
10 changes: 5 additions & 5 deletions src/match.lsc
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ transformAtom(mtch, path) ->
)~atNode(node)

transformAtoms(mtch, atomPaths) ->
Or([for elem atomPath in atomPaths: mtch~transformAtom(atomPath)])
Or([...for elem atomPath in atomPaths: mtch~transformAtom(atomPath)])

transformMatchTest(mtch, casePath) ->
{ outerGuard, atoms, binding, assertive, innerGuard } = casePath.node
{ discriminantRef } = mtch

And([
case outerGuard: outerGuard
case atoms and atoms.length > 0:
...if outerGuard: outerGuard
...if atoms and atoms.length > 0:
mtch~transformAtoms(casePath.get("atoms"))
case binding and assertive:
...if binding and assertive:
discriminantRef~matchesDestructuringPattern(binding)
case innerGuard:
...if innerGuard:
if binding:
// Transform referenced identifiers in the inner guard into accessors
// into the matched pattern.
Expand Down
2 changes: 1 addition & 1 deletion src/variables.lsc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import atLoc from 'ast-loc-utils/lib/placeAtLoc'
export getShadowingIdentifiers(declarationPath) ->
if not declarationPath.scope.parent: return []

[for idx i in declarationPath.node.declarations:
[...for idx i in declarationPath.node.declarations:
for val id in declarationPath.get(`declarations.${i}`).getBindingIdentifiers():
if declarationPath.scope.parent.hasBinding(id.name): id
]
Expand Down

0 comments on commit a20b583

Please sign in to comment.