| 653 | } |
| 654 | } |
| 655 | void verifyToTableMove ( ExprCall * expr ) { |
| 656 | if ( expr->arguments[0]->rtti_isMakeArray() ) { |
| 657 | auto ma = static_cast<ExprMakeArray *>(expr->arguments[0]); |
| 658 | if ( ma->values.size()==0 ) return; |
| 659 | auto recType = ma->recordType ? ma->recordType : ma->makeType; |
| 660 | if ( recType->isTuple() ) { |
| 661 | if ( recType->argTypes[0]->isString() ) { |
| 662 | das_set<const char *,hash_ccs,equalto_ccs> seen; |
| 663 | for ( const auto & arg : ma->values ) { |
| 664 | if ( arg->rtti_isMakeTuple() ) { |
| 665 | auto mt = static_cast<ExprMakeTuple *>(arg); |
| 666 | if ( mt->values.size()==2 ) { // its redundant |
| 667 | if ( mt->values[0]->rtti_isStringConstant() ) { |
| 668 | auto mc = static_cast<ExprConstString *>(mt->values[0]); |
| 669 | if ( seen.find(mc->text.c_str())==seen.end() ) { |
| 670 | seen.insert(mc->text.c_str()); |
| 671 | } else { |
| 672 | program->error("duplicate key in string=> table initialization", "", "", |
| 673 | mt->values[0]->at, CompilationError::already_declared_table); |
| 674 | } |
| 675 | } |
| 676 | } |
| 677 | } |
| 678 | } |
| 679 | } else { |
| 680 | das_set<vec4f,hash_vec4f,equalto_vec4f> seen; |
| 681 | for ( const auto & arg : ma->values ) { |
| 682 | if ( arg->rtti_isMakeTuple() ) { |
| 683 | auto mt = static_cast<ExprMakeTuple *>(arg); |
| 684 | if ( mt->values.size()==2 ) { // its redundant |
| 685 | if ( mt->values[0]->rtti_isConstant() ) { |
| 686 | auto mc = static_cast<ExprConst *>(mt->values[0]); |
| 687 | if ( seen.find(mc->value)==seen.end() ) { |
| 688 | seen.insert(mc->value); |
| 689 | } else { |
| 690 | program->error("duplicate key in table initialization", "", "", |
| 691 | mt->values[0]->at, CompilationError::already_declared_table); |
| 692 | } |
| 693 | } |
| 694 | } |
| 695 | } |
| 696 | } |
| 697 | } |
| 698 | } else { |
| 699 | if ( recType->isString() ) { |
| 700 | das_set<const char *,hash_ccs,equalto_ccs> seen; |
| 701 | for ( const auto & arg : ma->values ) { |
| 702 | if ( arg->rtti_isStringConstant() ) { |
| 703 | auto mc = static_cast<ExprConstString *>(arg); |
| 704 | if ( seen.find(mc->text.c_str())==seen.end() ) { |
| 705 | seen.insert(mc->text.c_str()); |
| 706 | } else { |
| 707 | program->error("duplicate key in string=> set initialization", "", "", |
| 708 | arg->at, CompilationError::already_declared_table); |
| 709 | } |
| 710 | } |
| 711 | } |
| 712 | } else { |