Skip to content

Commit d8dacfb

Browse files
committed
implement lshift and rshift functionality.
1 parent c8243a4 commit d8dacfb

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

src/builder.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as transform from './transform';
77
export { code, node, transform, Property, PropertyType, Span };
88
export { Edge } from './edge';
99
export { LoopChecker } from './loop-checker';
10+
export { ShiftChecker } from './shift-checker';
1011
export { ISpanAllocatorResult, SpanAllocator } from './span-allocator';
1112
export { Reachability } from './reachability';
1213

@@ -112,6 +113,34 @@ export class Builder {
112113
return new node.Pause(errorCode, reason);
113114
}
114115

116+
// Shift
117+
118+
/**
119+
* Create a node that packs bits into a field in
120+
* little endian format.
121+
*
122+
* state[field] <<= value;
123+
*
124+
* This node does not provide otherwise as this node must
125+
* consume bytes upon execution.
126+
*/
127+
public lshift(field: string, bits: number): node.Shift {
128+
return new node.Shift(field, bits, true);
129+
}
130+
131+
/**
132+
* Create a node that packs bits into a field in
133+
* big endian format.
134+
*
135+
* state[field] >>= value;
136+
*
137+
* This node does not provide otherwise as this node must
138+
* consume bytes upon execution.
139+
*/
140+
public rshift(field: string, bits: number): node.Shift {
141+
return new node.Shift(field, bits, false);
142+
}
143+
115144
// Span
116145

117146
/**

0 commit comments

Comments
 (0)