comparison nworker_c.rhope @ 171:a32afde77abb

Remove some debug Print calls from compiler
author Mike Pavone <pavone@retrodev.com>
date Sun, 08 May 2011 18:36:33 -0700
parents ac5c2d78663f
children 926b56a43f47
comparison
equal deleted inserted replaced
170:ac5c2d78663f 171:a32afde77abb
225 { 225 {
226 does <- If[[input num] >= [[node]Inputs >>]] {} 226 does <- If[[input num] >= [[node]Inputs >>]] {}
227 { 227 {
228 ,does not <- [[node]Input Types >>]Index[input num] 228 ,does not <- [[node]Input Types >>]Index[input num]
229 { 229 {
230 Print[[[[[["Input: "]Append[String[input num]]]Append[", count: "]]Append[String[count]]]Append[", wires: "]]Append[String[[[[node]Wires To >>]Index[ [input num]+[1] ]]Length]]]
231 count <- [~]Index[1] 230 count <- [~]Index[1]
232 ,does not <- If[[count] = [[[[node]Wires To >>]Index[[input num]+[1]]]Length]] 231 ,does not <- If[[count] = [[[[node]Wires To >>]Index[[input num]+[1]]]Length]]
233 { 232 {
234 does,does not <- [node]_Has Input Types[[input num]+[1]] 233 does,does not <- [node]_Has Input Types[[input num]+[1]]
235 } 234 }
240 Has Input Types?@NWorker Node[node:does,does not] 239 Has Input Types?@NWorker Node[node:does,does not]
241 { 240 {
242 If[[[node]Inputs >>] > [0]] 241 If[[[node]Inputs >>] > [0]]
243 { 242 {
244 does,does not <- _Has Input Types[node,0] 243 does,does not <- _Has Input Types[node,0]
245 { Print["does have input types"] }
246 { Print["does not have input types"] }
247 }{ 244 }{
248 does <- Yes 245 does <- Yes
249 } 246 }
250 } 247 }
251 248
326 323
327 Propagate Type[nodelist,dest,prog,worker,type:out] 324 Propagate Type[nodelist,dest,prog,worker,type:out]
328 { 325 {
329 If[[[dest]IO Num >>] >= [0]] 326 If[[[dest]IO Num >>] >= [0]]
330 { 327 {
331 Print[[[["Propagate Type, Index: "]Append[String[[dest]Index >>]]]Append[" io num: "]]Append[String[[dest]IO Num >>]]]
332 node <- [nodelist]Index[[dest]Index >>] 328 node <- [nodelist]Index[[dest]Index >>]
333 329
334 [[node]Input Types >>]Index[[dest]IO Num >>] 330 [[node]Input Types >>]Index[[dest]IO Num >>]
335 { 331 {
336 Print[["Existing type: "]Append[[existing type]Name >>]]
337 existing type <- [~]Index[0] 332 existing type <- [~]Index[0]
338 new count <- [[~]Index[1]]+[1] 333 new count <- [[~]Index[1]]+[1]
339 If[[[existing type]Name >>] = [[type]Name >>]] 334 If[[[existing type]Name >>] = [[type]Name >>]]
340 { 335 {
341 If[[[existing type]Variant >>] = [[type]Variant >>]] 336 If[[[existing type]Variant >>] = [[type]Variant >>]]
359 new type <- [[existing type]Set Variant[new variant]]Params <<[new params] 354 new type <- [[existing type]Set Variant[new variant]]Params <<[new params]
360 }{ 355 }{
361 new type <- Type Instance["Any Type"] 356 new type <- Type Instance["Any Type"]
362 } 357 }
363 }{ 358 }{
364 Print["No existing type info for this input"]
365 new type <- Val[type] 359 new type <- Val[type]
366 new count <- 1 360 new count <- 1
367 } 361 }
368 Print[[[["new type: "]Append[[new type]Name >>]]Append[", new count: "]]Append[String[new count]]]
369 new node <- [node]Input Types <<[ 362 new node <- [node]Input Types <<[
370 [ [node]Input Types >> ]Set[ [dest]IO Num >>, [[()]Append[new type]]Append[new count] ] 363 [ [node]Input Types >> ]Set[ [dest]IO Num >>, [[()]Append[new type]]Append[new count] ]
371 ] 364 ]
372 { Print["got new node"] }
373 out <- Infer Types Node[[nodelist]Set[[dest]Index >>, new node], new node, [dest]Index >>, prog, worker] 365 out <- Infer Types Node[[nodelist]Set[[dest]Index >>, new node], new node, [dest]Index >>, prog, worker]
374 }{ 366 }{
375 out <- nodelist 367 out <- nodelist
376 } 368 }
377 } 369 }
380 { 372 {
381 [[source node]Output Types >>]Index[output num] 373 [[source node]Output Types >>]Index[output num]
382 { 374 {
383 out <- Fold[Propagate Type[?, ?, prog, worker, ~], nodelist, dests] 375 out <- Fold[Propagate Type[?, ?, prog, worker, ~], nodelist, dests]
384 }{ 376 }{
385 Print[["Output type is missing for output #"]Append[String[output num]]]
386 out <- nodelist 377 out <- nodelist
387 } 378 }
388 } 379 }
389 380
390 Infer Types Node[nodelist,node,index,prog,worker:out] 381 Infer Types Node[nodelist,node,index,prog,worker:out]
393 { 384 {
394 extra <- [", worker: "]Append[[[node]Data >>]Name >>] 385 extra <- [", worker: "]Append[[[node]Data >>]Name >>]
395 }{ 386 }{
396 extra <- "" 387 extra <- ""
397 } 388 }
398 Print[[[[["Infer Types Node: "]Append[String[index]]]Append[", type: "]]Append[[node]Type >>]]Append[extra]]
399 If[[[node]Type >>] = ["const"]] 389 If[[[node]Type >>] = ["const"]]
400 { 390 {
401 const type <- Blueprint Of[[node]Data >>] 391 const type <- Blueprint Of[[node]Data >>]
402 [(Int8(),UInt8(),Int16(),UInt16(),Int32(),UInt32(),Int64(),UInt64(), 392 [(Int8(),UInt8(),Int16(),UInt16(),Int32(),UInt32(),Int64(),UInt64(),
403 Type Instance(),Worker Literal(),List(),List Leaf(),String(),String Slice(),String Cat())]Find[=[const type, ?]] 393 Type Instance(),Worker Literal(),List(),List Leaf(),String(),String Slice(),String Cat())]Find[=[const type, ?]]
455 nextnode <- [node]Output Types <<[ [()]Append[outtype] ] 445 nextnode <- [node]Output Types <<[ [()]Append[outtype] ]
456 }{ 446 }{
457 worker name <- [[node]Data >>]Name >> 447 worker name <- [[node]Data >>]Name >>
458 [prog]Is Method?[worker name] 448 [prog]Is Method?[worker name]
459 { 449 {
460 Print[[["Infer Types: "]Append[worker name]]Append[" is a method"]]
461 first arg type <- [[[node]Input Types >>]Index[0]]Index[0] 450 first arg type <- [[[node]Input Types >>]Index[0]]Index[0]
462 If[[[first arg type]Name >>] = ["Any Type"]] 451 If[[[first arg type]Name >>] = ["Any Type"]]
463 { 452 {
464 Print["No type info for first arg"]
465 outtypes <- Fold[Append[?, Type Instance["Any Type"]], (), Range[0, [node]Inputs >>]] 453 outtypes <- Fold[Append[?, Type Instance["Any Type"]], (), Range[0, [node]Inputs >>]]
466 Print[["outtypes length: "]Append[String[Length[outtypes]]]]
467 nextnode <- [node]Output Types <<[ outtypes ] 454 nextnode <- [node]Output Types <<[ outtypes ]
468 }{ 455 }{
469 worker def <- [prog]Find Method[worker name, first arg type] 456 worker def <- [prog]Find Method[worker name, first arg type]
470 { 457 {
471 new worker name <- [[worker name]Append["@"]]Append[[first arg type]Name >>] 458 new worker name <- [[worker name]Append["@"]]Append[[first arg type]Name >>]
472 new ref <- [prog]Find Worker[new worker name] {} { 459 new ref <- [prog]Find Worker[new worker name] {} {
473 Print[["Could not find worker ref for "]Append[new worker name]] 460 Print[["Could not find worker ref for "]Append[new worker name]]
474 } 461 }
475 nextnode <- [[node]Output Types <<[outtypes] 462 nextnode <- [[node]Output Types <<[outtypes]
476 ]Data <<[new ref] 463 ]Data <<[new ref]
477 Print[["New worker name:"]Append[new worker name]]
478 }{ 464 }{
479 //TODO: Return errors instead of printing them 465 //TODO: Return errors instead of printing them
480 Print[ 466 Print[
481 [[[[["Type " 467 [[[[["Type "
482 ]Append[[first arg type]Name >>] 468 ]Append[[first arg type]Name >>]
485 ]Append[" in worker "] 471 ]Append[" in worker "]
486 ]Append[ [worker]Name >> ]] 472 ]Append[ [worker]Name >> ]]
487 } 473 }
488 } 474 }
489 }{ 475 }{
490 Print[[["Infer Types: "]Append[worker name]]Append[" is not a method"]]
491 worker def <- [prog]Find Worker Def[worker name] {} 476 worker def <- [prog]Find Worker Def[worker name] {}
492 { Print["Error, could not find worker def"] } 477 { Print["Error, could not find worker def"] }
493 nextnode <- [node]Output Types <<[ outtypes ] 478 nextnode <- [node]Output Types <<[ outtypes ]
494 } 479 }
495 outtypes <- [worker def]Output Types >> 480 outtypes <- [worker def]Output Types >>
496 } 481 }
497 } 482 }
498 }{ 483 }{
499 Print["Skipping node because input type info not present"]
500 out <- nodelist 484 out <- nodelist
501 } 485 }
502 } 486 }
503 } 487 }
504 } 488 }
506 } 490 }
507 491
508 Val[nextnode] 492 Val[nextnode]
509 { 493 {
510 nextlist <- [nodelist]Set[index, nextnode] 494 nextlist <- [nodelist]Set[index, nextnode]
511 { Print["Calling Propagate types on descdendants of this node"] }
512 out <- Fold[Propagate Types[?, ?, ?, prog, worker, nextnode], nextlist, [nextnode]Wires From >>] 495 out <- Fold[Propagate Types[?, ?, ?, prog, worker, nextnode], nextlist, [nextnode]Wires From >>]
513 } 496 }
514 } 497 }
515 498
516 Infer Types@NWorker[worker,prog:out] 499 Infer Types@NWorker[worker,prog:out]
517 { 500 {
518 Print[["Infer Types: "]Append[[worker]Name >>]]
519 out <- [worker]Nodes <<[Fold[Infer Types Node[?, ?, ?, prog, worker], [worker]Nodes >>, [worker]Nodes >>]] 501 out <- [worker]Nodes <<[Fold[Infer Types Node[?, ?, ?, prog, worker], [worker]Nodes >>, [worker]Nodes >>]]
520 } 502 }
521 503
522 Add Worker Call@NWorker[worker,tocall:out,node index] 504 Add Worker Call@NWorker[worker,tocall:out,node index]
523 { 505 {
939 out <- Val[after maybe] 921 out <- Val[after maybe]
940 } 922 }
941 } 923 }
942 } 924 }
943 after save <- Fold[Save Result[?, ?, node index], with call, Range[0, save outs]] 925 after save <- Fold[Save Result[?, ?, node index], with call, Range[0, save outs]]
944 Print[["Last NumParams is now "]Append[String[[after save]Last NumParams >>]]]
945 } 926 }
946 927
947 Compile Node[worker,program,func,nodes,current:out,out worker] 928 Compile Node[worker,program,func,nodes,current:out,out worker]
948 { 929 {
949 node index <- [nodes]Index[current] 930 node index <- [nodes]Index[current]