Skip to content
Merged
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
61 changes: 4 additions & 57 deletions std/std.solc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import std.opcodes.{mstore, mload, sstore, sload};

pragma no-patterson-condition ABIEncode, Num;
pragma no-coverage-condition ABIDecode, MemoryType;

Expand Down Expand Up @@ -85,8 +87,6 @@ export {
memberAccessBase,
memory(*),
memory_ref,
mload,
mstore,
ne,
not,
or,
Expand All @@ -105,10 +105,6 @@ export {
sha256,
slice(*),
slice_,
sloadViaWord,
sload_,
sstore_,
sstoreViaWord,
storage(*),
storeBytesFromMemory,
string,
Expand Down Expand Up @@ -805,21 +801,10 @@ data mapping(member, index) = mapping(word) ;

// --- Low-level memory ops

function mload(a:word) -> word {
let res: word;
assembly { res := mload(a) }
return res;
}

function mstore(a:word, v:word) -> () {
assembly { mstore(a,v) }
}

function strlen(s:memory(string)) -> word {
match s { | memory(a) => return mload(a); }
}


// --- Memory Utilities ---

// Memory in solidity is bump allocated in a single arena
Expand Down Expand Up @@ -1540,20 +1525,6 @@ pragma no-coverage-condition MemberAccessProxy, LVA, RVA, CStructField, Assign;
pragma no-bounded-variable-condition LVA, RVA;
// -- storage

function sload_(x:word) -> word {
let res: word;
assembly {
res := sload(x)
}
return res;
}

function sstore_(a:word, v:word) -> () {
assembly { sstore(a,v) }
}



forall self.
class self:StorageSize {
function size(x:Proxy(self)) -> word;
Expand Down Expand Up @@ -1623,7 +1594,6 @@ forall a b. a:StorageSize, b:StorageSize => instance (a,b):StorageSize {
}
}


forall self.
class self:StorageType {
function load(ptr:word) -> self;
Expand All @@ -1632,33 +1602,10 @@ class self:StorageType {

instance word:StorageType {
function load(ptr:word) -> word {
let r:word;
assembly {
r := sload(ptr)
}
return r;
return sload(ptr);
}
function store(ptr:word, value:word) -> () {
assembly {
sstore(ptr, value)
}
}
}

forall a. a:Typedef(word) =>
function sloadViaWord(ptr:word) -> a {
let r:word;
assembly {
r := sload(ptr)
}
return Typedef.abs(r);
}

forall a. a:Typedef(word) =>
function sstoreViaWord(ptr:word, value:a) -> () {
let w: word = Typedef.rep(value);
assembly {
sstore(ptr, w)
sstore(ptr, value);
}
}

Expand Down
1 change: 1 addition & 0 deletions test/examples/dispatch/hashes.solc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import std.{*};
import std.dispatch.{*};
import std.opcodes.{mstore};

// Build a memory(bytes) holding the three-byte string "abc".
function abcBytes() -> memory(bytes) {
Expand Down
1 change: 1 addition & 0 deletions test/examples/dispatch/memory.solc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import std.{*};
import std.dispatch.{*};
import std.opcodes.{mstore};

contract C {
public function dirty_allocate() -> memory(bytes) {
Expand Down
4 changes: 3 additions & 1 deletion test/examples/dispatch/stringid.solc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import std.{*};
import std.{memory, string, Typedef, log1, allocate_memory, mstore, uint256};
import std.{memory, string, Typedef, log1, allocate_memory, uint256};
import std.dispatch.{*};
import std.opcodes.{mstore, mload};

pragma no-patterson-condition ;
pragma no-coverage-condition ;
pragma no-bounded-variable-condition ;
Expand Down
Loading