Skip to content

Commit

Permalink
Combined preprocessor topic
Browse files Browse the repository at this point in the history
  • Loading branch information
timothymcmackin committed Jan 30, 2025
1 parent 4fe7150 commit 40f93b6
Show file tree
Hide file tree
Showing 11 changed files with 489 additions and 0 deletions.
412 changes: 412 additions & 0 deletions gitlab-pages/docs/compiling/preprocessor.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions gitlab-pages/docs/compiling/src/preprocessor/euro.jsligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type t = nat;

export const add = (a: t, b: t): t => a + b;

export const one: t = 1n;
export const two: t = 2n;
6 changes: 6 additions & 0 deletions gitlab-pages/docs/compiling/src/preprocessor/euro.mligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
type t = nat

let add (a, b : t * t) : t = a + b

let one : t = 1n
let two : t = 2n
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// This file is gitlab-pages/docs/preprocessor/src/import/euro_namespace_public.jsligo

@public
namespace Euro {
export type t = nat;
export const add = (a: t, b: t) : t => a + b;
export const one: t = 1n;
export const two: t = 2n;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#import "gitlab-pages/docs/compiling/src/preprocessor/euro_namespace_public.jsligo" "Euro_import"

type euro_balance = Euro_import.Euro.t;

const add_tip = (s: euro_balance): euro_balance =>
Euro_import.Euro.add(s, Euro_import.Euro.one);
12 changes: 12 additions & 0 deletions gitlab-pages/docs/compiling/src/preprocessor/includereset.jsligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export namespace MyContract {
export type storage = int;
export type result = [list<operation>, storage];

@entry const increment = (delta : int, storage : storage) : result => [[], storage + delta];

@entry const decrement = (delta : int, storage : storage) : result => [[], storage - delta];

#if INCLUDE_RESET
@entry const reset = (_u : unit, _storage : storage) : result => [[], 0];
#endif
}
12 changes: 12 additions & 0 deletions gitlab-pages/docs/compiling/src/preprocessor/includereset.mligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module MyContract = struct
type storage = int
type result = operation list * storage

[@entry] let increment (delta : int) (storage : storage) : result = [],storage + delta

[@entry] let decrement (delta : int) (storage : storage) : result = [],storage - delta

#if INCLUDE_RESET
[@entry] let reset () (_storage : storage) : result = [], 0
#endif
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#import "gitlab-pages/docs/compiling/src/preprocessor/euro.jsligo" "Euro"

type storage = Euro.t;

const tip = (s : storage) : storage =>
Euro.add (s, Euro.one);
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import "gitlab-pages/docs/compiling/src/preprocessor/euro.mligo" "Euro"

type storage = Euro.t

let tip (s : storage) : storage = Euro.add (s, Euro.one)
14 changes: 14 additions & 0 deletions gitlab-pages/docs/compiling/src/preprocessor/ungrouped.mligo
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
type storage =
[@layout:comb]
{ tokenPool : nat ;
xtzPool : tez ;
lqtTotal : nat ;
selfIsUpdatingTokenPool : bool ;
freezeBaker : bool ;
manager : address ;
tokenAddress : address ;
#if FA2
tokenId : nat ;
#endif
lqtAddress : address ;
}
1 change: 1 addition & 0 deletions gitlab-pages/website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const sidebars = {
"testing/michelson_testing"
],
"Compiling": [
"compiling/preprocessor",
"compiling/compiling",
"compiling/deploying"
],
Expand Down

0 comments on commit 40f93b6

Please sign in to comment.