Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
type: 'str',
},
{
name: 'value',
type: 'str',
},
{
name: 'namespace',
type: 'option-str',
},
],
operands: 3,
check: true,
};
METADATA[Op.DynamicAttr] = {
name: 'DynamicAttr',
mnemonic: 'apnd_dynattr',
before: null,
stackChange: -1,
ops: [
{
name: 'name',
type: 'str',
},
{
name: 'trusting',
type: 'bool',
},
{
name: 'namespace',
type: 'option-str',
STATEMENTS.add(SexpOpcodes.DynamicAttr, ([, name, value, namespace]) => [
op('Expr', value),
op(Op.DynamicAttr, name, false, namespace),
]);
STATEMENTS.add(SexpOpcodes.TrustingDynamicAttr, ([, name, value, namespace]) => [
op('Expr', value),
op(Op.DynamicAttr, name, true, namespace),
]);
if (!validate(tag, lastUpdated)) {
vm.env.scheduleUpdateModifier(modifier, manager);
this.lastUpdated = value(tag);
}
}
}
APPEND_OPCODES.add(Op.StaticAttr, (vm, { op1: _name, op2: _value, op3: _namespace }) => {
let name = vm[CONSTANTS].getString(_name);
let value = vm[CONSTANTS].getString(_value);
let namespace = _namespace ? vm[CONSTANTS].getString(_namespace) : null;
vm.elements().setStaticAttribute(name, value, namespace);
});
APPEND_OPCODES.add(Op.DynamicAttr, (vm, { op1: _name, op2: trusting, op3: _namespace }) => {
let name = vm[CONSTANTS].getString(_name);
let reference = check(vm.stack.pop(), CheckReference);
let value = reference.value();
let namespace = _namespace ? vm[CONSTANTS].getString(_namespace) : null;
let attribute = vm.elements().setDynamicAttribute(name, value, !!trusting, namespace);
if (!isConst(reference)) {
vm.updateWith(new UpdateDynamicAttributeOpcode(reference, attribute));
}
});
export class UpdateDynamicAttributeOpcode extends UpdatingOpcode {
public type = 'patch-element';
public tag: Tag;