Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/code/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export * from './span';
export * from './store';
export * from './test';
export * from './update';
export * from './unpack';
export * from './value';
13 changes: 13 additions & 0 deletions src/code/unpack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Field } from "./field";

export class Unpack extends Field {
constructor (
name: string,
field:string,
public readonly bigEndian:boolean
){
const endian_str = bigEndian ? 'be': 'le';
super('match', `unpack_${endian_str}_${field}`, name, field);
}
}

1 change: 1 addition & 0 deletions src/container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class Container {
Store: this.combine((impl) => impl.code.Store),
Test: this.combine((impl) => impl.code.Test),
Update: this.combine((impl) => impl.code.Update),
Unpack: this.combine((impl) => impl.code.Unpack),
Value: this.combine((impl) => impl.code.Value),
};
}
Expand Down
8 changes: 6 additions & 2 deletions src/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,13 @@ export class Frontend {
} else if (code instanceof source.code.Update) {
res = new codeImpl.Update(
new frontend.code.Update(prefixed, code.field, code.value));


} else if (code instanceof source.code.Unpack) {
res = new codeImpl.Unpack(
new frontend.code.Unpack(prefixed, code.field, code.bigEndian));
}
// External callbacks
} else if (code instanceof source.code.Span) {
else if (code instanceof source.code.Span) {
res = new codeImpl.Span(new frontend.code.Span(code.name));
} else if (code instanceof source.code.Match) {
res = new codeImpl.Match(new frontend.code.Match(code.name));
Expand Down
1 change: 1 addition & 0 deletions src/implementation/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ICodeImplementation {
readonly Span: new(c: code.Span) => IWrap<code.Span>;
readonly Store: new(c: code.Store) => IWrap<code.Store>;
readonly Test: new(c: code.Test) => IWrap<code.Test>;
readonly Unpack: new(c: code.Unpack) => IWrap<code.Unpack>;
readonly Update: new(c: code.Update) => IWrap<code.Update>;
readonly Value: new(c: code.Value) => IWrap<code.Value>;
}
8 changes: 8 additions & 0 deletions test/fixtures/a-implementation/code/unpack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { code } from '../../../../src/frontend';
import { Code } from './base';

export class Unpack extends Code<code.Unpack> {
public build(): string {
return '';
}
}
8 changes: 8 additions & 0 deletions test/fixtures/implementation/code/unpack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { code } from '../../../../src/frontend';
import { Code } from './base';

export class Unpack extends Code<code.Unpack> {
public build(): string {
return '';
}
}