Skip to content

Commit

Permalink
chore: create ScriptNum type and use it instead of i64 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
tdelabro authored Sep 18, 2024
1 parent 4899c4f commit 7c82b47
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 92 deletions.
3 changes: 2 additions & 1 deletion src/script/engine.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const Stack = @import("stack.zig").Stack;
const Script = @import("lib.zig").Script;
const ScriptNum = @import("lib.zig").ScriptNum;
const ScriptFlags = @import("lib.zig").ScriptFlags;
const arithmetic = @import("opcodes/arithmetic.zig");
const Opcode = @import("opcodes/constant.zig").Opcode;
Expand Down Expand Up @@ -410,7 +411,7 @@ pub const Engine = struct {
fn opSize(self: *Engine) !void {
const top_value = try self.stack.pop();
const len = top_value.len;
const result: i64 = @intCast(len);
const result: ScriptNum = @intCast(len);

try self.stack.pushElement(top_value);
try self.stack.pushInt(result);
Expand Down
2 changes: 2 additions & 0 deletions src/script/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ pub const stack = @import("stack.zig");
pub const arithmetic = @import("opcodes/arithmetic.zig");
const StackError = @import("stack.zig").StackError;

pub const ScriptNum = i64;

/// Maximum number of bytes pushable to the stack
const MAX_SCRIPT_ELEMENT_SIZE = 520;

Expand Down
Loading

0 comments on commit 7c82b47

Please sign in to comment.