Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
b.memberExpression(
b.thisExpression(), b.identifier('endian')),
b.binaryExpression(
'!==',
b.memberExpression(
b.identifier('obj'), b.identifier(child_name)),
b.literal(66))
)));
// data.readUInt8(0) !== 66
}
write_stmts.push(
b.expressionStatement(b.callExpression(
b.memberExpression(
b.thisExpression(),
b.identifier(`write${child_type}`)),
[b.memberExpression(
b.identifier('obj'),
b.identifier(child_name))])));
}
break;
case 'list':
{
let child_name = child.attr('name').value();
let child_type = child.attr('type').value();
let fieldref = parseOp(child.get('*'), 'obj');
if (fieldref !== null) {
read_stmts.push(b.variableDeclaration(
'var',
[b.variableDeclarator(
b.identifier(`${child_name}_length`),
fieldref)]));
throw new Error(
"Shouldn't be able to get to valueparam before enums are parsed");
}
let enum_map = klasses.getClass('XTypeBuffer').enums;
let value_mask_type = child.attr('value-mask-type').value();
let value_mask_name = child.attr('value-mask-name').value();
let value_list_name = child.attr('value-list-name').value();
if (! enum_map.has(value_list_name)) {
console.error(`FIXME: The stupid cases for ${value_list_name}`);
continue;
}
let enum_class_name = enum_map.get(value_list_name).name;
read_stmts.push(b.expressionStatement(b.assignmentExpression(
'=',
b.memberExpression(
b.identifier('obj'), b.identifier(value_mask_name)),
b.callExpression(b.memberExpression(
b.parenthesizedExpression(b.newExpression(
b.identifier(enum_class_name),
[])),
b.identifier('decode')),
[b.callExpression(
b.memberExpression(
b.thisExpression(),
b.identifier(`read${value_mask_type}`)),
[])]
))));
write_stmts.push(b.variableDeclaration(
'var',
[b.variableDeclarator(
}
let enum_map = klasses.getClass('XTypeBuffer').enums;
let value_mask_type = child.attr('value-mask-type').value();
let value_mask_name = child.attr('value-mask-name').value();
let value_list_name = child.attr('value-list-name').value();
if (! enum_map.has(value_list_name)) {
console.error(`FIXME: The stupid cases for ${value_list_name}`);
continue;
}
let enum_class_name = enum_map.get(value_list_name).name;
read_stmts.push(b.expressionStatement(b.assignmentExpression(
'=',
b.memberExpression(
b.identifier('obj'), b.identifier(value_mask_name)),
b.callExpression(b.memberExpression(
b.parenthesizedExpression(b.newExpression(
b.identifier(enum_class_name),
[])),
b.identifier('decode')),
[b.callExpression(
b.memberExpression(
b.thisExpression(),
b.identifier(`read${value_mask_type}`)),
[])]
))));
write_stmts.push(b.variableDeclaration(
'var',
[b.variableDeclarator(
b.identifier('value'),
b.memberExpression(b.identifier('obj'), b.identifier('value'))
b.identifier('connectionArgs'),
b.memberExpression(
b.identifier('GraphQLRelay'),
b.identifier('connectionArgs'),
false
)
)]
));
}
}
declarations.push(
b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('getType'),
b.memberExpression(
b.identifier('resolveMap'),
b.identifier('getType'),
false
)
)]
)
);
declarations.push(
b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('registerType'),
b.memberExpression(
b.identifier('resolveMap'),
b.identifier('registerType'),
false
function moduleExportsExpression(id: string): any {
return b.memberExpression(
b.memberExpression(
b.identifier('module'),
b.identifier('exports'),
false
),
b.literal(id),
true
);
}
boundMethods.map(identifier =>
b.expressionStatement(
b.callExpression(
b.memberExpression(
b.memberExpression(
b.thisExpression(),
identifier
),
b.identifier('bind')
),
[b.thisExpression()]
)
)
)
export async function wrapJsonFile(modulePath: string, context: PaeckchenContext): Promise {
const data = JSON.parse(await context.host.readFile(modulePath));
return b.program([
b.expressionStatement(
b.assignmentExpression(
'=',
b.memberExpression(
b.identifier('module'),
b.identifier('exports'),
false
),
buildValue(data)
)
)
]);
}
b.identifier('nodeField'),
b.memberExpression(
b.identifier('Node'),
b.identifier('nodeField'),
false
)
)]
)
);
}
declarations.push(
b.variableDeclaration('var',
[b.variableDeclarator(
b.identifier('registerType'),
b.memberExpression(
b.identifier('resolveMap'),
b.identifier('registerType'),
false
)
)]
)
);
return declarations;
}
function mapMemberProperties(properties: CBaseList, meta: Object) {
const head = properties.slice(0, properties.length - 1);
const lastProperty = last(properties);
const isIndex = lastProperty.constructor.name === 'Index';
const right = mapExpression(lastProperty, meta);
const isComputed = (right.type === 'Literal' || isIndex);
let left;
if (head.length === 1) {
left = mapExpression(head[0], meta);
} else {
left = mapMemberProperties(head, meta);
}
return b.memberExpression(left, right, isComputed);
}
function wrapExternalModule(modulePath: string, context: PaeckchenContext): Promise {
const external = context.config.externals[modulePath] === false
? b.objectExpression([])
: b.identifier(context.config.externals[modulePath] as string);
return Promise.resolve(b.program([
b.expressionStatement(
b.assignmentExpression(
'=',
b.memberExpression(
b.identifier('module'),
b.identifier('exports'),
false
),
external
)
)
]));
}