Generalize assertion/message type wire name expression position
This commit is contained in:
parent
c771abbf2e
commit
879dbd93b8
|
@ -145,8 +145,7 @@ export default class SyndicateParser extends _original_Parser {
|
||||||
node.formals = node.params;
|
node.formals = node.params;
|
||||||
delete node.params; // eww
|
delete node.params; // eww
|
||||||
if (this.eat(tt.eq)) {
|
if (this.eat(tt.eq)) {
|
||||||
if (!this.match(tt.string)) { this.unexpected(null, tt.string); }
|
node.wireName = this.parseExpression();
|
||||||
node.wireName = this.parseLiteral(this.state.value, "StringLiteral");
|
|
||||||
}
|
}
|
||||||
this.semicolon();
|
this.semicolon();
|
||||||
return this.finishNode(node, "SyndicateTypeDefinition");
|
return this.finishNode(node, "SyndicateTypeDefinition");
|
||||||
|
|
|
@ -450,10 +450,11 @@ export default declare((api, options) => {
|
||||||
|
|
||||||
SyndicateTypeDefinition(path, state) {
|
SyndicateTypeDefinition(path, state) {
|
||||||
const { node } = path;
|
const { node } = path;
|
||||||
path.replaceWith(template(`const ID = RECORD.makeConstructor(WIRE, FORMALS);`)({
|
path.replaceWith(template(`const ID = RECORD.makeBasicConstructor(WIRE, FORMALS);`)({
|
||||||
ID: node.id,
|
ID: node.id,
|
||||||
RECORD: state.RecordID,
|
RECORD: state.RecordID,
|
||||||
WIRE: node.wireName || t.stringLiteral(node.id.name),
|
WIRE: node.wireName ||
|
||||||
|
template.expression(`Symbol.for(N)`)({N: t.stringLiteral(node.id.name)}),
|
||||||
FORMALS: t.arrayExpression(node.formals.map((f) => t.stringLiteral(f.name))),
|
FORMALS: t.arrayExpression(node.formals.map((f) => t.stringLiteral(f.name))),
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
|
@ -153,7 +153,7 @@ defineType("SyndicateTypeDefinition", {
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
wireName: {
|
wireName: {
|
||||||
validate: assertNodeType("StringLiteral"),
|
validate: assertNodeType("Expression"),
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue