Skip to content
Snippets Groups Projects
Commit 0e7430c8 authored by Daniel Olsson's avatar Daniel Olsson
Browse files

Finished the lab with the line number changes

parent 059cf5f6
No related branches found
No related tags found
No related merge requests found
......@@ -20,8 +20,8 @@ using namespace std;
int main(int argc, char **argv)
{
int cur = 0;
char *lines[35000];
char line[700];
char *lines[16536];
char line[80];
// Fix num lines, num columns, strdup-1
FILE *fin = fopen("bible.txt", "r");
if (fin==NULL){
......@@ -30,7 +30,7 @@ int main(int argc, char **argv)
}
while (!feof(fin)) {
getline(line, fin);
lines[cur] = (char*) malloc(strlen(line) + 1);
lines[cur] = (char*) malloc(strlen(line)+1);
strcpy(lines[cur], line);
cur++;
}
......
......@@ -24,7 +24,6 @@ static void* launchThread(void *in)
while (1) {
pthread_mutex_lock(&lock);
n = data->current++;
//printf("%d\n",data->current);
if (n >= data->len){
pthread_mutex_unlock(&lock);
break;
......@@ -32,7 +31,6 @@ static void* launchThread(void *in)
data->fn(&data->data[n]);
pthread_mutex_unlock(&lock);
}
//rintf("Jag är ute\n" );
return NULL;
}
......@@ -79,7 +77,7 @@ int main(int argc, char **argv)
for (int i=0; i<100; i++) {
vals[i] = i*1.5;
}
launchParallel(8 /* Increase this if no error occurs */, vals, 100, mul2);
launchParallel(4 /* Increase this if no error occurs */, vals, 100, mul2);
for (int i=0; i<100; i++) {
if (vals[i] != 1.5*2*i) {
......
function adjustLines(res, macrofile, invokedFile, invokedLine )
sz =size(res.args)
dump(res)
temp = copy(res)
for i=1:sz[1]
if isa(temp.args[i], LineNumberNode)
if (String(temp.args[i].file) == macrofile)
file = temp.args[i].line = invokedLine
if(typeof(res) == Expr)
#Loop thorugh all args
for i = 1:size(res.args)[1]
#Check if is a LineNumberNode
if(typeof(res.args[i]) == LineNumberNode)
#Check if it is the macrofile and then change the file and line
#otherwise do nothing
if(String(res.args[i].file) == String(macrofile))
res.args[i] = LineNumberNode(invokedLine, invokedFile)
end
#Recusive expression if res.args[i] is a Expr
elseif(typeof(res) == Expr)
res.args[i] = adjustLines(res.args[i], macrofile, invokedFile, invokedLine)
end
#println(i)
#println(res.args[i].file)
else
#println(i)
#println("Nej")
end
#println(i)
#println(res.args[i].args)
end
return res
end
......@@ -24,8 +22,6 @@ macro doWhile(block, cond)
# println("__source__ ", __source__)
#println("cond ", cond)
#println("block ", block)
res = quote
#error("TODO: Your code here")
$(esc(block))
......@@ -34,7 +30,6 @@ macro doWhile(block, cond)
end
end
res = adjustLines(res,@__FILE__(), __source__.file, __source__.line)
println("Here is the whole")
println(res) # Should not print any lines referencing dowhile.jl
res
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment