Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
APPEND_OPCODES.add(Op.PushRemoteElement, vm => {
let elementRef = vm.stack.pop>();
let nextSiblingRef = vm.stack.pop>>();
let element: Simple.Element;
let nextSibling: Option;
if (isConstReference(elementRef)) {
element = elementRef.value();
} else {
let cache = new ReferenceCache(elementRef);
element = cache.peek();
vm.updateWith(new Assert(cache));
}
if (isConstReference(nextSiblingRef)) {
nextSibling = nextSiblingRef.value();
} else {
let cache = new ReferenceCache(nextSiblingRef);
nextSibling = cache.peek();
vm.updateWith(new Assert(cache));
}
vm.elements().pushRemoteElement(element, nextSibling);
});
flush(env: Environment): Option {
let { reference, element } = this;
if (isConstReference(reference)) {
let value = reference.value();
this.attributeManager.setAttribute(env, element, value, this.namespace);
return null;
} else {
let cache = this.cache = new ReferenceCache(reference);
let value = cache.peek();
this.attributeManager.setAttribute(env, element, value, this.namespace);
return new PatchElementOpcode(this);
}
}
}
let insertBefore: Maybe;
let guid = guidRef.value() as string;
if (isConst(elementRef)) {
element = check(elementRef.value(), CheckElement);
} else {
let cache = new ReferenceCache(elementRef as Reference);
element = check(cache.peek(), CheckElement);
vm.updateWith(new Assert(cache));
}
if (insertBeforeRef.value() !== undefined) {
if (isConst(insertBeforeRef)) {
insertBefore = check(insertBeforeRef.value(), CheckOption(CheckNode));
} else {
let cache = new ReferenceCache(insertBeforeRef as Reference>);
insertBefore = check(cache.peek(), CheckOption(CheckNode));
vm.updateWith(new Assert(cache));
}
}
let block = vm.elements().pushRemoteElement(element, guid, insertBefore);
if (block) vm.associateDestroyable(block);
});
let element: Simple.Element;
let nextSibling: Option;
if (isConstReference(elementRef)) {
element = elementRef.value();
} else {
let cache = new ReferenceCache(elementRef);
element = cache.peek();
vm.updateWith(new Assert(cache));
}
if (isConstReference(nextSiblingRef)) {
nextSibling = nextSiblingRef.value();
} else {
let cache = new ReferenceCache(nextSiblingRef);
nextSibling = cache.peek();
vm.updateWith(new Assert(cache));
}
vm.elements().pushRemoteElement(element, nextSibling);
});
(vm, { op1: target }) => {
let reference = check(vm.stack.pop(), CheckReference);
if (isConst(reference)) {
if (!reference.value()) {
vm.goto(target);
}
} else {
let cache = new ReferenceCache(reference);
if (!cache.peek()) {
vm.goto(target);
}
vm.updateWith(new Assert(cache));
}
},
OpcodeKind.Mut
vm => {
let reference = check(vm.stack.peek(), CheckReference);
if (!isConst(reference)) {
vm.updateWith(Assert.initialize(new ReferenceCache(reference)));
}
},
OpcodeKind.Mut
APPEND_OPCODES.add(Op.PushDynamicComponentManager, vm => {
let stack = vm.stack;
let reference = stack.pop>>();
let cache = isConst(reference) ? undefined : new ReferenceCache>(reference);
let definition = cache ? cache.peek() : reference.value();
stack.push(definition);
stack.push(definition.manager);
if (cache) {
vm.updateWith(new Assert(cache));
}
});
APPEND_OPCODES.add(Op.JumpUnless, (vm, { op1: target }) => {
let reference = check(vm.stack.pop(), CheckReference);
if (isConst(reference)) {
if (!reference.value()) {
vm.goto(target);
}
} else {
let cache = new ReferenceCache(reference);
if (!cache.peek()) {
vm.goto(target);
}
vm.updateWith(new Assert(cache));
}
});