Skip to content

Commit

Permalink
engine: define arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
bpowers committed Jul 28, 2024
1 parent 7fdab48 commit 45139a4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/simlin-engine/src/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,17 @@ pub struct ModuleDeclaration {
pub(crate) off: usize, // offset within the parent module
}

#[derive(Clone, Debug)]
pub struct ArrayDefinition {
pub(crate) dimensions: Vec<usize>,

Check failure on line 85 in src/simlin-engine/src/bytecode.rs

View workflow job for this annotation

GitHub Actions / clippy

field `dimensions` is never read

error: field `dimensions` is never read --> src/simlin-engine/src/bytecode.rs:85:16 | 84 | pub struct ArrayDefinition { | --------------- field in this struct 85 | pub(crate) dimensions: Vec<usize>, | ^^^^^^^^^^ | = note: `ArrayDefinition` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis = note: `-D dead-code` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(dead_code)]`
}

// these are things that will be shared across bytecode runlists
#[derive(Clone, Debug)]
pub struct ByteCodeContext {
pub(crate) graphical_functions: Vec<Vec<(f64, f64)>>,
pub(crate) modules: Vec<ModuleDeclaration>,
pub(crate) arrays: Vec<ArrayDefinition>,

Check failure on line 93 in src/simlin-engine/src/bytecode.rs

View workflow job for this annotation

GitHub Actions / clippy

field `arrays` is never read

error: field `arrays` is never read --> src/simlin-engine/src/bytecode.rs:93:16 | 90 | pub struct ByteCodeContext { | --------------- field in this struct ... 93 | pub(crate) arrays: Vec<ArrayDefinition>, | ^^^^^^ | = note: `ByteCodeContext` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis
}

#[derive(Clone, Debug, Default)]
Expand Down
1 change: 1 addition & 0 deletions src/simlin-engine/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1745,6 +1745,7 @@ impl<'module> Compiler<'module> {
context: Rc::new(ByteCodeContext {
graphical_functions: self.graphical_functions,
modules: self.module_decls,
arrays: vec![],
}),
compiled_initials,
compiled_flows,
Expand Down
26 changes: 26 additions & 0 deletions src/simlin-engine/src/project_io.proto
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,29 @@ message Project {
repeated Model models = 3;
Source source = 5;
};

// the following are for serializing and deserializing the bytecode/data sent to the engine for a model

enum BuiltinId {
UNSPECIFIED = 0;
Abs = 1;
Arccos = 2;
Arcsin = 3;
Arctan = 4;
Cos = 5;
Exp = 6;
Inf = 7;
Int = 8;
Ln = 9;
Log10 = 10;
Max = 11;
Min = 12;
Pi = 13;
Pulse = 14;
Ramp = 15;
SafeDiv = 16;
Sin = 17;
Sqrt = 18;
Step = 19;
Tan = 20;
};

0 comments on commit 45139a4

Please sign in to comment.