Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

20230206 refresh compile file #32

Open
wants to merge 24 commits into
base: base
Choose a base branch
from

Conversation

prozacchiwawa
Copy link
Contributor

Add embed-file, compile-file and defconst forms.

embed-file and compile-file include content at compile time; embed-file is like the new #embed in C and compile-file includes the compiled contents of the module.

Use embed-file like this:

embedded-data.clinc:
(2 3 4)

embed-test.clsp
(mod (xor-data)
  (include sha256tree.clib)
  (embed-file secret-data sexp embedded-data.clinc)
  (defconst secret-hash (sha256tree secret-data))
  (logxor xor-data secret-hash)
  )

The hash of (2 3 4) is 0x6fcb06b1fe29d132bb37f3a21b86d7cf03d636bf6230aa206486bef5e68f9873 (opc -H)

Compiling this program contains the same constant:

(logxor 2 (q . 0x6fcb06b1fe29d132bb37f3a21b86d7cf03d636bf6230aa206486bef5e68f9873))

So it gives the chialisp compiler the data from disk to use in your program, freeing the user from having to embed compilation products manually or do other tricks. The recent addition of get_dependencies also tracks these dependencies so tooling can
determine whether downstream compilation is needed.

the embed-file form can use "sexp", "hex" and "bin" formats for input, and compile-file will produce the compiled program, which is useful for programs that need to know the puzzle hash of another program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants