-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from typing import Iterable | ||
from starkware.starknet.core.os.syscall_handler import SyscallHandlerBase, OsExecutionHelper | ||
from starkware.cairo.lang.vm.relocatable import RelocatableValue, MaybeRelocatable | ||
from starkware.cairo.lang.vm.memory_segments import MemorySegmentManager | ||
|
||
class SyscallHandler(SyscallHandlerBase): | ||
""" | ||
A handler for system calls; used by the BusinessLogic entry point execution. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
segments: MemorySegmentManager, | ||
): | ||
super().__init__(segments=segments, initial_syscall_ptr=None) | ||
|
||
def set_syscall_ptr(self, syscall_ptr: RelocatableValue): | ||
assert self._syscall_ptr is None, "syscall_ptr is already set." | ||
self._syscall_ptr = syscall_ptr | ||
|
||
def allocate_segment(self, data: Iterable[MaybeRelocatable]) -> RelocatableValue: | ||
segment_start = self.segments.add() | ||
self.segments.write_arg(ptr=segment_start, arg=data) | ||
return segment_start |