Skip to content

Commit

Permalink
clean up insert-macro-args
Browse files Browse the repository at this point in the history
  • Loading branch information
z80dev committed Oct 29, 2024
1 parent 5df15ea commit 3e14271
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion main.rkt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#lang racket
#lang racket/base
(require racket/cmdline "puff/puff.rkt")
(require racket/match)

(define filename "")
(define compilation-output 'bytecode)
Expand Down
13 changes: 10 additions & 3 deletions puff/phases/macros.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
6 changes: 0 additions & 6 deletions test/Counter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@
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 {
function addUints(uint256, uint256) external returns (uint256);
}

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 {
Expand Down

0 comments on commit 3e14271

Please sign in to comment.