MCPcopy Create free account
hub / github.com/Gecode/gecode / arrayOutput

Function arrayOutput

gecode/flatzinc/parser.tab.cpp:527–561  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

525}
526
527AST::Node* arrayOutput(AST::Call* ann) {
528 AST::Array* a = NULL;
529
530 if (ann->args->isArray()) {
531 a = ann->args->getArray();
532 } else {
533 a = new AST::Array(ann->args);
534 }
535
536 std::ostringstream oss;
537
538 oss << "array" << a->a.size() << "d(";
539 for (unsigned int i=0; i<a->a.size(); i++) {
540 AST::SetLit* s = a->a[i]->getSet();
541 if (s->empty())
542 oss << "{}, ";
543 else if (s->interval)
544 oss << s->min << ".." << s->max << ", ";
545 else {
546 oss << "{";
547 for (unsigned int j=0; j<s->s.size(); j++) {
548 oss << s->s[j];
549 if (j<s->s.size()-1)
550 oss << ",";
551 }
552 oss << "}, ";
553 }
554 }
555
556 if (!ann->args->isArray()) {
557 a->a[0] = NULL;
558 delete a;
559 }
560 return new AST::String(oss.str());
561}
562
563/*
564 * The main program

Callers 1

yyparseFunction · 0.85

Calls 6

isArrayMethod · 0.80
getArrayMethod · 0.80
getSetMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected