Skip to content

Commit

Permalink
Pass field name as argument to pseudo-function.
Browse files Browse the repository at this point in the history
Closes #373.
  • Loading branch information
flatheadmill committed Nov 29, 2016
1 parent e4b160c commit accc286
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,18 @@ function visitPropertySerialize (parameters, body, fields) {
body.forEach(function (node) {
assert(node.type == 'ExpressionStatement')
node = node.expression
assert(node.type == 'AssignmentExpression')

assert(node.left.type == 'MemberExpression')
assert(node.left.object.name == 'object')
assert(node.left.property.type == 'Identifier')
var name = node.left.property.name
dump(node)
assert(node.type == 'CallExpression')
assert(node.callee.name == '_')

assert(node.right.type == 'CallExpression')
assert(node.right.callee.name = '$_')
var arg = node.arguments[0]
assert(arg.type == 'MemberExpression')
assert(arg.object.name == 'object')
assert(arg.property.type == 'Identifier')
var name = arg.property.name

var value = node.right.arguments[0].value
var arg = node.arguments[1]
var value = arg.value

fields.push({
name: name,
Expand Down
2 changes: 1 addition & 1 deletion t/language/source/minimal.packet.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Bargle.
packets.object = function (object) {
object.value = $_(16)
_(object.value, 16)
}

0 comments on commit accc286

Please sign in to comment.