diff --git a/main.rkt b/main.rkt index d061da7..bb0518f 100644 --- a/main.rkt +++ b/main.rkt @@ -1,5 +1,6 @@ -#lang racket +#lang racket/base (require racket/cmdline "puff/puff.rkt") +(require racket/match) (define filename "") (define compilation-output 'bytecode) diff --git a/puff/phases/macros.rkt b/puff/phases/macros.rkt index 8473e92..ac5b6ab 100644 --- a/puff/phases/macros.rkt +++ b/puff/phases/macros.rkt @@ -14,9 +14,16 @@ (eq? 'macro-arg (car code)))) (define (insert-macro-args code data) - (if (is-macro-arg (car code)) - (cons (hash-ref data (cadar code)) (cdr code)) - (cons (car code) (insert-macro-args (cdr code))))) + (define (handle-macro-arg code) + ;; (cadar '((1 2 3) 4 5)) = 2, i.e. second element of first element in list + ;; (cadar '((macro-arg foo))) = 'foo + (cons (hash-ref data (cadar code)) (insert-macro-args (cdr code) data))) + (define (continue code) + (cons (car code) (insert-macro-args (cdr code) data))) + (cond + ((empty? code) '()) + ((is-macro-arg (car code)) (handle-macro-arg code)) + (else (continue code)))) (define (get-macro-body code data) (let* ([name (cadr code)] diff --git a/test/Counter.t.sol b/test/Counter.t.sol index b515fd5..0faabab 100644 --- a/test/Counter.t.sol +++ b/test/Counter.t.sol @@ -2,8 +2,6 @@ pragma solidity ^0.8.13; import {Test, console} from "forge-std/Test.sol"; -import {Counter} from "../src/Counter.sol"; -import {CreateX} from "../src/CreateX.sol"; import {PuffDeployer, HuffDeployer} from "../src/Deployers.sol"; interface IAddsUints { @@ -11,14 +9,10 @@ interface IAddsUints { } contract CounterTest is Test { - CreateX public createx; PuffDeployer public puffDeployer; - HuffDeployer public huffDeployer; function setUp() public { - createx = new CreateX(); puffDeployer = new PuffDeployer(); - huffDeployer = new HuffDeployer(); } function test_addNumbers() public {