Skip to content

Commit e9009da

Browse files
author
robertDurst
committed
multi import works
1 parent dcd8e18 commit e9009da

File tree

5 files changed

+45
-251
lines changed

5 files changed

+45
-251
lines changed

examples/LinkedList.fish

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import intListHandler : "../examples/intListHandler.fish"
2+
3+
Uat {
4+
intListHandler list
5+
}
6+
7+
Ufn {
8+
9+
}

examples/foo.fish

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Uat {
2+
23
}
34

45
Ufn {

examples/test.fish

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
import intListHandler : "../examples/intListHandler.fish"
1+
import LinkedList : "../examples/LinkedList.fish"
22

33
start {
4-
dec [int] list = [1,2,3]
5-
dec int size = 3
6-
dec intListHandler bar = new intListHandler { list: list, size: size}
7-
8-
bar...printFoo(void)
9-
bar...push(10)
10-
bar...printFoo(void)
11-
bar...removeByIndex(1)
12-
bar...printFoo(void)
13-
14-
bar...setAtIndex(1, 22)
15-
bar...setAtIndex(20, 22)
16-
bar...printFoo(void)
4+
175
}

out.c

Lines changed: 0 additions & 182 deletions
Original file line numberDiff line numberDiff line change
@@ -1,182 +0,0 @@
1-
/**
2-
* Do not alter! This code is generated by the sailfishc
3-
* compiler and might/will break if anything changed.
4-
*/
5-
6-
#include <stdio.h>
7-
#include <stdlib.h>
8-
9-
// -------- STDLIB_START ------- //
10-
void
11-
print_bool(int i)
12-
{
13-
if (i == 1)
14-
printf("%s", "true");
15-
else
16-
printf("%s", "false");
17-
}
18-
void
19-
print_flt(float f)
20-
{
21-
printf("%f", f);
22-
};
23-
void
24-
print_int(int i)
25-
{
26-
printf("%d", i);
27-
};
28-
void
29-
print_str(char* s)
30-
{
31-
printf("%s", s);
32-
};
33-
// -------- STDLIB_END ------- //
34-
35-
typedef struct _Node_
36-
{
37-
struct _Node_* next;
38-
int data;
39-
} Node;
40-
41-
Node*
42-
construct_Node(Node* next, int data)
43-
{
44-
Node* a____struct___generated = (Node*)malloc(sizeof(Node));
45-
a____struct___generated->next = next;
46-
a____struct___generated->data = data;
47-
return a____struct___generated;
48-
}
49-
50-
int
51-
has_next(Node* own)
52-
{
53-
int ret = (own->next != NULL);
54-
return ret;
55-
}
56-
void
57-
set_next(Node* own, Node* node)
58-
{
59-
own->next = node;
60-
}
61-
Node*
62-
next(Node* own)
63-
{
64-
return own->next;
65-
}
66-
int
67-
data(Node* own)
68-
{
69-
return own->data;
70-
}
71-
typedef struct _Stack_
72-
{
73-
struct _Node_* head;
74-
int size;
75-
} Stack;
76-
77-
Stack*
78-
construct_Stack(Node* head, int size)
79-
{
80-
Stack* a____struct___generated = (Stack*)malloc(sizeof(Stack));
81-
a____struct___generated->head = head;
82-
a____struct___generated->size = size;
83-
return a____struct___generated;
84-
}
85-
86-
int
87-
is_empty(Stack* own)
88-
{
89-
return (own->size == 0);
90-
}
91-
int
92-
size(Stack* own)
93-
{
94-
return own->size;
95-
}
96-
int
97-
peek(Stack* own)
98-
{
99-
int i = 0;
100-
if (is_empty(own) == 1)
101-
{
102-
}
103-
else
104-
{
105-
i = data(own->head);
106-
}
107-
108-
return i;
109-
}
110-
void
111-
push(Stack* own, Node* node)
112-
{
113-
set_next(node, own->head);
114-
own->head = node;
115-
own->size = own->size + 1;
116-
}
117-
void
118-
pop(Stack* own)
119-
{
120-
if (is_empty(own) == 1)
121-
{
122-
}
123-
else
124-
{
125-
own->head = next(own->head);
126-
own->size = own->size - 1;
127-
}
128-
}
129-
void
130-
print_(Stack* own, Node* node)
131-
{
132-
if (node != NULL)
133-
{
134-
print_int(data(node));
135-
print_str(" ");
136-
print_(own, next(node));
137-
}
138-
else
139-
{
140-
}
141-
}
142-
void
143-
print(Stack* own)
144-
{
145-
print_str("Stack contents: ");
146-
print_(own, own->head);
147-
print_str("\n");
148-
}
149-
int
150-
main()
151-
{
152-
Node* a = construct_Node(NULL, 10);
153-
Node* b = construct_Node(NULL, 20);
154-
Node* c = construct_Node(NULL, 30);
155-
Node* d = construct_Node(NULL, 40);
156-
Node* e = construct_Node(NULL, 50);
157-
Stack* s = construct_Stack(NULL, 0);
158-
push(s, a);
159-
push(s, b);
160-
push(s, c);
161-
print(s);
162-
print_str("Size: ");
163-
print_int(size(s));
164-
print_str("\tTop: ");
165-
print_int(peek(s));
166-
print_str("\n");
167-
pop(s);
168-
pop(s);
169-
pop(s);
170-
pop(s);
171-
pop(s);
172-
print_str("Size: ");
173-
print_int(size(s));
174-
print_str("\tTop: ");
175-
print_int(peek(s));
176-
print_str("\n");
177-
push(s, d);
178-
push(s, e);
179-
push(s, c);
180-
push(s, b);
181-
print(s);
182-
}

0 commit comments

Comments
 (0)