Changeset 0e767dc in tol
- Timestamp:
- Jul 3, 2012, 9:33:03 PM (14 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 8e7b274
- Parents:
- 0d63276
- Location:
- tol
- Files:
-
- 5 edited
-
OIS/oisloader.cpp (modified) (8 diffs)
-
btol/bgrammar/class.cpp (modified) (23 diffs)
-
btol/bgrammar/oprimp.cpp (modified) (4 diffs)
-
btol/bgrammar/spfuninst.cpp (modified) (7 diffs)
-
btol/bgrammar/tol_bclass.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tol/OIS/oisloader.cpp
r0d63276 r0e767dc 510 510 mbr->isStatic_ = isStatic!=0; 511 511 mbr->isGood_ = true; 512 mbr->BuildMethod(); 513 mbr->BuildStatic(); 512 mbr->BuildAll(); 514 513 } 515 514 else … … 842 841 else if(mode==BCLASSMODE) 843 842 { 844 BClass* cls = BClass::PredeclareClass (name);843 BClass* cls = BClass::PredeclareClassIfNeeded(name); 845 844 Ensure(cls); 846 845 Ensure(Read(*cls,object_)); … … 1041 1040 ERead(className, set_); 1042 1041 //Std(BText("\nBOisLoader::ReadNextObject Predeclared Class ")+className); 1043 BClass::PredeclareClass (className);1042 BClass::PredeclareClassIfNeeded(className); 1044 1043 } 1045 1044 } … … 1090 1089 ERead(className, set_); 1091 1090 //Std(BText("\nBOisLoader::ReadNextObject Predeclared Class ")+className); 1092 BClass::PredeclareClass (className);1091 BClass::PredeclareClassIfNeeded(className); 1093 1092 } 1094 1093 } … … 1155 1154 ERead(offset, object_); 1156 1155 set_->SetPos(offset); 1156 BGrammar::IncLevel(); 1157 1157 if(control_.oisEngine_.oisVersion_>="02.15") 1158 1158 { … … 1164 1164 ERead(className, set_); 1165 1165 //Std(BText("\nBOisLoader::ReadNextObject Predeclared Class ")+className); 1166 BClass::PredeclareClass (className);1166 BClass::PredeclareClassIfNeeded(className); 1167 1167 } 1168 1168 } … … 1205 1205 BText className; 1206 1206 ERead(className, set_); 1207 BClass::PredeclareClass (className);1207 BClass::PredeclareClassIfNeeded(className); 1208 1208 } 1209 1209 } … … 1224 1224 BSyntaxObject* r=NULL; 1225 1225 x.Set().PrepareStore(s); 1226 BGrammar::IncLevel();1227 1226 for(n=1; n<=s; n++) 1228 1227 { -
tol/btol/bgrammar/class.cpp
r0d63276 r0e767dc 66 66 isStatic_ (false), 67 67 static_ (NULL), 68 description_ ("") 68 description_ (""), 69 type_ (NULL), 70 class_ (NULL), 71 struct_ (NULL) 69 72 { 70 73 } … … 85 88 isStatic_ (false), 86 89 static_ (NULL), 87 description_ ("") 90 description_ (""), 91 type_ (NULL), 92 class_ (NULL), 93 struct_ (NULL) 88 94 { 89 95 Copy(mbr); 90 96 } 97 98 99 //-------------------------------------------------------------------- 100 void CleanLeftAndRightChar(BText& expression, char begin, char end) 101 //-------------------------------------------------------------------- 102 { 103 int fst = 0; 104 int lst = expression.Length()-1; 105 while(expression[fst]==begin) { fst++; } 106 while(expression[lst]==end ) { lst--; } 107 expression = expression.SubString(fst,lst); 108 } 109 110 91 111 //-------------------------------------------------------------------- 92 112 BMember::BMember(BMemberOwner* parent, List* branch) … … 104 124 isStatic_ (false), 105 125 static_ (NULL), 106 description_ ("") 126 description_ (""), 127 type_ (NULL), 128 class_ (NULL), 129 struct_ (NULL) 107 130 { 108 131 List* cdr; … … 159 182 else if(expression[0]=='{') 160 183 { 161 expression = expression.SubString(1,expression.Length()-2);184 CleanLeftAndRightChar(expression,'{','}'); 162 185 } 163 186 int posEq = expression.Find("="); … … 265 288 { 266 289 name_ = simpleDec.SubString(p0+1,p1-1); 290 CleanLeftAndRightChar(name_,'{','}'); 267 291 } 268 292 } 269 293 } 270 294 //Cleaning open and close parenthesis 271 if(declaration_[0]=='{') 272 { 273 declaration_=declaration_.SubString(1,declaration_.Length()-2); 274 } 295 CleanLeftAndRightChar(declaration_,'{','}'); 275 296 } 276 297 //Checking mandatory information: name and declaration. … … 293 314 I2(" of Class ", " de Class ")+parent->getFullName()); 294 315 } 295 if(parent->OwnerType()==BMemberOwner::BCLASS) 296 { 297 BuildMethod(); 298 BuildStatic(); 299 } 316 BuildAll(); 300 317 } 301 318 … … 360 377 isStatic_ = mbr.isStatic_; 361 378 static_ = mbr.static_; 379 type_ = mbr.type_; 380 class_ = mbr.class_; 381 struct_ = mbr.struct_; 362 382 if(method_) { method_->IncNRefs(); } 363 383 if(static_) { static_->IncNRefs(); } … … 483 503 } 484 504 } 505 506 //-------------------------------------------------------------------- 507 int BMember::BuildType() 508 //! Builds type information 509 //-------------------------------------------------------------------- 510 { 511 if(isMethod_) { type_ = GraCode(); } 512 else 513 { 514 BText typeDec = declaration_+" "; 515 typeDec.Replace(BText(" ")+name_+" ",""); 516 typeDec.Compact(); 517 class_ = FindClass(typeDec,-1); 518 if(class_) { type_ = GraNameBlock(); } 519 else 520 { 521 struct_ = FindStruct(typeDec); 522 if(struct_) { type_ = GraSet(); } 523 else 524 { 525 type_ = BGrammar::FindByName(typeDec,false); 526 if(!type_) 527 { 528 isGood_ = false; 529 Error(I2("Unknown type declaration of member ", 530 "Tipo descponocido en declaración de miembro ")+ 531 BParser::Unparse(branch_,"","\n")+ 532 I2(" of Class ", " de Class ")+parent_->getFullName() ); 533 return(-1); 534 } 535 } 536 } 537 } 538 return(0); 539 } 540 541 //-------------------------------------------------------------------- 542 int BMember::BuildAll() 543 //-------------------------------------------------------------------- 544 { 545 if(parent_->OwnerType()==BMemberOwner::BCLASS) 546 { 547 BuildMethod(); 548 BuildStatic(); 549 } 550 BuildType(); 551 return(0); 552 } 553 485 554 //-------------------------------------------------------------------- 486 555 bool BMember::HasDefVal() const … … 747 816 if(!parent) { return(false); } 748 817 if(this==parent) { return(true); } 749 return(InheritesFrom(parent->getFullNameRef())); 818 BClassByNameHash::const_iterator iterA; 819 BClassByNameHash& ah = *ascentHash_; 820 for(iterA=ah.begin(); iterA!=ah.end(); iterA++) 821 { 822 if(iterA->second==parent) { return(true); } 823 } 824 return(false); 825 //return(InheritesFrom(parent->getFullNameRef())); 750 826 //return(InheritesFrom(parent->Name())); 751 827 } … … 819 895 { 820 896 if(!isGood_) { return(false); } 821 const BText & dec = newMember->declaration_;897 const BText* dec = &(newMember->declaration_); 822 898 const BText& name = newMember->name_; 823 assert(name.HasName()&& dec .HasName());899 assert(name.HasName()&& dec->HasName()); 824 900 825 901 if(OwnerType()==BCLASS) … … 847 923 BMbrNum* mbrNum = FindMbrNum(name); 848 924 BMember* member = (mbrNum)?mbrNum->member_:NULL; 925 if(member) 926 { 927 if(member->type_ == newMember->type_) 928 { 929 if( ((member->type_==GraSet())&&member->struct_&&(member->struct_==newMember->struct_)) 930 || 931 ((member->type_==GraNameBlock())&&member->class_&&(member->class_==newMember->class_)) ) 932 { 933 dec = &(member->declaration_); 934 } 935 } 936 } 849 937 //Searches for existant member with same declaration but no default value 850 BMember* mbrDec = FindDecMember( dec);938 BMember* mbrDec = FindDecMember(*dec); 851 939 //Searches for existant member with same declaration and with default value 852 BMember* mbrDef = FindDefMember(dec); 940 BMember* mbrDef = FindDefMember(*dec); 941 853 942 bool isMethod = newMember->isMethod_; 854 943 if(!member) … … 858 947 (*memberHash_)[name] = newMbrNum; 859 948 //It's also added to correspondent map hashed by declaration 860 if(hasDefVal) { (*mbrDefHash_)[ dec] = newMember; }861 else { (*mbrDecHash_)[ dec] = newMember; }949 if(hasDefVal) { (*mbrDefHash_)[*dec] = newMember; } 950 else { (*mbrDecHash_)[*dec] = newMember; } 862 951 if(isMethod && !hasDefVal) { notImplementedMethods_++; } 863 952 } … … 895 984 memberHash_->erase(name); 896 985 assert(!FindMember(name)); 897 mbrDefHash_->erase( dec);898 assert(!FindDefMember( dec));986 mbrDefHash_->erase(*dec); 987 assert(!FindDefMember(*dec)); 899 988 (*memberHash_)[name] = newMbrNum; 900 (*mbrDefHash_)[ dec] = newMember;989 (*mbrDefHash_)[*dec] = newMember; 901 990 newMember->firstParent_ = mbrDef->firstParent_; 902 991 } … … 907 996 memberHash_->erase(name); 908 997 assert(!FindMember(name)); 909 mbrDecHash_->erase( dec);910 assert(!FindDecMember( dec));911 (*memberHash_)[name] = newMbrNum;912 (*mbrDefHash_)[ dec] = newMember;998 mbrDecHash_->erase(*dec); 999 assert(!FindDecMember(*dec)); 1000 (*memberHash_)[name] = newMbrNum; 1001 (*mbrDefHash_)[*dec] = newMember; 913 1002 if(isMethod) 914 1003 { … … 953 1042 " \n class:"+Name()+ 954 1043 " \n member name:"+name+ 955 " \n member declaration:"+ dec+"\n");1044 " \n member declaration:"+*dec+"\n"); 956 1045 */ 957 1046 return(ok); … … 1193 1282 __destroy(NULL) 1194 1283 { 1284 if(name=="@BsrMaster") 1285 printf(""); 1195 1286 CreateMemberHashes(); 1196 1287 CreateParentHashes(); … … 1665 1756 1666 1757 //-------------------------------------------------------------------- 1667 BClass* BClass::PredeclareClass( 1758 static BClass* FindClassInNameBlock( 1759 const BText& name, 1760 BUserNameBlock*& unb ) 1761 //-------------------------------------------------------------------- 1762 { 1763 BClass* cls = NULL; 1764 BSyntaxObject* obj; 1765 int pos = name.Find("::",0); 1766 if(pos>=0) 1767 { 1768 BText prefix; 1769 BText suffix; 1770 prefix = name.SubString(0,pos-1); 1771 suffix = name.SubString(pos+2,name.Length()); 1772 if(!unb) 1773 { 1774 obj = GraNameBlock()->FindOperand(prefix,false); 1775 if(obj && obj->Grammar()==GraNameBlock()) 1776 { 1777 unb = (BUserNameBlock*)obj; 1778 } 1779 } 1780 else 1781 { 1782 BNameBlock& nb = unb->Contens(); 1783 obj = nb.Member(prefix); 1784 if(obj && obj->Grammar()==GraNameBlock()) 1785 { 1786 unb = (BUserNameBlock*)obj; 1787 } 1788 else 1789 { 1790 unb = NULL; 1791 } 1792 } 1793 if(unb) 1794 { 1795 cls = FindClassInNameBlock(suffix, unb); 1796 } 1797 } 1798 else if(unb) 1799 { 1800 BNameBlock& nb = unb->Contens(); 1801 obj = nb.Member(name); 1802 if(obj && obj->Mode()==BCLASSMODE) 1803 { 1804 cls = (BClass*)obj; 1805 } 1806 } 1807 return(cls); 1808 } 1809 1810 1811 //-------------------------------------------------------------------- 1812 static BClass* FindNonMemberClass(const BText& name, int defined) 1813 1814 /*! Searches a user class wich name is name and returns it. 1815 * If itsn't exists returns NIL. 1816 */ 1817 //-------------------------------------------------------------------- 1818 { 1819 BClass* cls = BStackManager::FindClass(name); 1820 if(!cls) 1821 { 1822 BObjClassify oc(GraAnything(),BCLASSMODE); 1823 cls= (BClass*)BGrammar::SymbolTable().Search(oc, name); 1824 } 1825 return(cls); 1826 } 1827 1828 //-------------------------------------------------------------------- 1829 BClass* FindClass(const BText& name, int defined) 1830 1831 /*! Searches a user class wich name is name and returns it. 1832 * If itsn't exists returns NIL. 1833 */ 1834 //-------------------------------------------------------------------- 1835 { 1836 BSyntaxObject* result = NULL; 1837 BUserNameBlock* unb = NULL; 1838 BClass* cls = FindClassInNameBlock(name, unb); 1839 if(!cls && BNameBlock::Current()) 1840 { 1841 result = BNameBlock::Current()->Member(name); 1842 if(result && (result->Mode()==BCLASSMODE)) 1843 { 1844 cls = (BClass*)result; 1845 } 1846 } 1847 if(!cls) 1848 { 1849 cls = BStackManager::FindClass(name); 1850 } 1851 if(!cls) 1852 { 1853 result = BNameBlock::LocalMember(name); 1854 if(result && (result->Mode()==BCLASSMODE)) 1855 { 1856 cls = (BClass*)result; 1857 } 1858 } 1859 if(!cls) 1860 { 1861 BObjClassify oc(GraAnything(),BCLASSMODE); 1862 cls= (BClass*)BGrammar::SymbolTable().Search(oc, name); 1863 } 1864 if(!cls) 1865 { 1866 result = BNameBlock::UsingMember(name); 1867 if(result && (result->Mode()==BCLASSMODE)) 1868 { 1869 cls = (BClass*)result; 1870 } 1871 } 1872 if(cls && (defined>=0) && (cls->isDefined_!=(defined!=0))) 1873 { 1874 cls = NULL; 1875 } 1876 return(cls); 1877 } 1878 1879 //-------------------------------------------------------------------- 1880 BClass* BClass::GetClassIfExist(const BText& name) 1881 //-------------------------------------------------------------------- 1882 { 1883 if(name=="@BsrMaster") 1884 printf(""); 1885 BClass* old = NULL; 1886 if(name.HasName()) 1887 { 1888 BUserNameBlock* bnbP = BNameBlock::Building(); 1889 if(bnbP) 1890 { 1891 old = BStackManager::FindClass(name); 1892 if(old && (old->Level()!=BGrammar::Level())) 1893 { 1894 old = NULL; 1895 } 1896 } 1897 else 1898 { 1899 old = FindClass(name,-1); 1900 } 1901 } 1902 return(old); 1903 } 1904 1905 //-------------------------------------------------------------------- 1906 BClass* BClass::PredeclareClassIfNeeded(const BText& name) 1907 //-------------------------------------------------------------------- 1908 { 1909 BClass* class_ = BClass::GetClassIfExist(name); 1910 if(!class_) 1911 { 1912 class_ = new BClass(name); 1913 } 1914 return(class_); 1915 }; 1916 1917 1918 //-------------------------------------------------------------------- 1919 BClass* BClass::PredeclareNewClass( 1668 1920 const BText& name, 1669 1921 BClass*& old, … … 1671 1923 //-------------------------------------------------------------------- 1672 1924 { 1673 old = NULL;1925 old = BClass::GetClassIfExist(name); 1674 1926 BClass* class_ = NULL; 1675 if(name.HasName()) 1676 { 1677 old = FindClass(name,-1); 1678 //Checking existent class with the same name 1679 if(old && old->isDefined_) 1680 { 1681 ok = false; 1682 Error(BText("Class '") + name + 1683 I2("' is already defined as ", 1684 "' ya fue definida como \"") + old->Dump() + "\"\n"); 1685 } 1686 else if(old) 1687 { 1688 class_ = old; 1689 } 1690 else 1691 { 1692 class_ = new BClass(name); 1693 } 1927 //Checking existent class with the same name 1928 if(old && old->isDefined_) 1929 { 1930 ok = false; 1931 Error(BText("Class '") + name + 1932 I2("' is already defined as ", 1933 "' ya fue definida como \"") + old->Dump() + "\"\n"); 1934 } 1935 else if(old) 1936 { 1937 class_ = old; 1938 } 1939 else 1940 { 1941 class_ = new BClass(name); 1694 1942 } 1695 1943 return(class_); … … 1697 1945 1698 1946 //-------------------------------------------------------------------- 1699 BClass* BClass::Predeclare Class(const BText& name)1700 //-------------------------------------------------------------------- 1701 { 1702 BClass* old;1947 BClass* BClass::PredeclareNewClass(const BText& name) 1948 //-------------------------------------------------------------------- 1949 { 1950 BClass* class_; 1703 1951 bool ok; 1704 return(Predeclare Class(name, old, ok));1952 return(PredeclareNewClass(name, class_, ok)); 1705 1953 }; 1706 1954 … … 1733 1981 { 1734 1982 name = tok->Name(); 1735 class_ = Predeclare Class(name, old, ok);1983 class_ = PredeclareNewClass(name, old, ok); 1736 1984 ok = (class_!=NULL); 1737 1985 memberLst=NULL; … … 1742 1990 tok = (BToken*)((List*)(cdr->car()))->car(); 1743 1991 name = tok->Name(); 1744 class_ = Predeclare Class(name, old, ok);1992 class_ = PredeclareNewClass(name, old, ok); 1745 1993 ok = (class_!=NULL); 1746 1994 cdr = cdr->cdr(); … … 1824 2072 //Class without inheriting clause 1825 2073 name = tok->Name(); 1826 class_ = Predeclare Class(name, old, ok);2074 class_ = PredeclareNewClass(name, old, ok); 1827 2075 ok = (class_!=NULL); 1828 2076 memberLst = cdr; … … 1869 2117 } 1870 2118 1871 //--------------------------------------------------------------------1872 static BClass* FindClassInNameBlock(1873 const BText& name,1874 BUserNameBlock*& unb )1875 //--------------------------------------------------------------------1876 {1877 BClass* cls = NULL;1878 BSyntaxObject* obj;1879 int pos = name.Find("::",0);1880 if(pos>=0)1881 {1882 BText prefix;1883 BText suffix;1884 prefix = name.SubString(0,pos-1);1885 suffix = name.SubString(pos+2,name.Length());1886 if(!unb)1887 {1888 obj = GraNameBlock()->FindOperand(prefix,false);1889 if(obj && obj->Grammar()==GraNameBlock())1890 {1891 unb = (BUserNameBlock*)obj;1892 }1893 }1894 else1895 {1896 BNameBlock& nb = unb->Contens();1897 obj = nb.Member(prefix);1898 if(obj && obj->Grammar()==GraNameBlock())1899 {1900 unb = (BUserNameBlock*)obj;1901 }1902 else1903 {1904 unb = NULL;1905 }1906 }1907 if(unb)1908 {1909 cls = FindClassInNameBlock(suffix, unb);1910 }1911 }1912 else if(unb)1913 {1914 BNameBlock& nb = unb->Contens();1915 obj = nb.Member(name);1916 if(obj && obj->Mode()==BCLASSMODE)1917 {1918 cls = (BClass*)obj;1919 }1920 }1921 return(cls);1922 }1923 1924 //--------------------------------------------------------------------1925 BClass* FindClass(const BText& name, int defined)1926 1927 /*! Searches a user class wich name is name and returns it.1928 * If itsn't exists returns NIL.1929 */1930 //--------------------------------------------------------------------1931 {1932 BSyntaxObject* result = NULL;1933 BUserNameBlock* unb = NULL;1934 BClass* cls = FindClassInNameBlock(name, unb);1935 if(!cls && BNameBlock::Current())1936 {1937 result = BNameBlock::Current()->Member(name);1938 if(result && (result->Mode()==BCLASSMODE))1939 {1940 cls = (BClass*)result;1941 }1942 }1943 if(!cls)1944 {1945 cls = BStackManager::FindClass(name);1946 }1947 if(!cls)1948 {1949 result = BNameBlock::LocalMember(name);1950 if(result && (result->Mode()==BCLASSMODE))1951 {1952 cls = (BClass*)result;1953 }1954 }1955 if(!cls)1956 {1957 BObjClassify oc(GraAnything(),BCLASSMODE);1958 cls= (BClass*)BGrammar::SymbolTable().Search(oc, name);1959 }1960 if(!cls)1961 {1962 result = BNameBlock::UsingMember(name);1963 if(result && (result->Mode()==BCLASSMODE))1964 {1965 cls = (BClass*)result;1966 }1967 }1968 if(cls && (defined>=0) && (cls->isDefined_!=(defined!=0)))1969 {1970 cls = NULL;1971 }1972 return(cls);1973 }1974 2119 1975 2120 //-------------------------------------------------------------------- -
tol/btol/bgrammar/oprimp.cpp
r0d63276 r0e767dc 1354 1354 { 1355 1355 BNameBlock& nb = ((BUserNameBlock*)var)->Contens(); 1356 if(cls->Name()=="@BsrMaster") 1357 printf(""); 1356 1358 if(!nb.IsInstanceOf(cls)) 1357 1359 { 1358 1360 BText bText = BParser::Unparse(b); 1361 BText but = ""; 1362 if(nb.Class()) 1363 { 1364 but = I2(" but it's an instance of ", 1365 " sino de " )+nb.Class()->FullName(); 1366 } 1367 else 1368 { 1369 but = I2(" nor any other class.", 1370 " ni de ninguna otra clase."); 1371 } 1359 1372 Error(bText + I2(" is not a NameBlock instance of ", 1360 1373 " no es un NameBlock instancia de ") + 1361 cls->FullName() );1374 cls->FullName()+but); 1362 1375 DESTROY(var); 1363 1376 } … … 1599 1612 BStruct* str = NIL; 1600 1613 BClass* cls = NIL; 1614 structs_ [n] = NIL; 1615 classes_ [n] = NIL; 1601 1616 bool carIsList = dec->car()->IsListClass(); 1602 1617 List* decLst = carIsList?Tree::treNode((List*) dec):(List*)dec; … … 1614 1629 structs_ [n] = str; 1615 1630 classes_ [n] = cls; 1631 if(str) { str->IncNRefs(); } 1632 if(cls) { cls->IncNRefs(); } 1616 1633 dec = dec->cdr(); 1617 1634 } … … 1875 1892 declare_ = ""; 1876 1893 define_ = ""; 1894 for(int n = 0; n<maxArg_; n++) 1895 { 1896 if(classes_[n]) { classes_[n]->DecNRefs(); } 1897 if(structs_[n]) { structs_[n]->DecNRefs(); } 1898 } 1877 1899 } 1878 1900 -
tol/btol/bgrammar/spfuninst.cpp
r0d63276 r0e767dc 137 137 int numParam) 138 138 139 /*! Returns true if the number of branchin a tree is correct139 /*! Returns true if the number and types of branches in a tree is correct 140 140 */ 141 141 //-------------------------------------------------------------------- … … 143 143 BList* lst = NIL; 144 144 BList* aux = NIL; 145 BInt n = BSpecialFunction::NumBranches(tre); 146 if(numParam) 147 { 148 for(BInt i=0; i<n; i++) 149 { 150 BInt j = Minimum(i, numParam-1); 151 BGrammar* gra = graParam[j]; 152 assert(gra); 153 List* branch = Branch(tre,i+1); 154 assert(branch); 155 BSyntaxObject* arg = gra->EvaluateTree(branch); 156 if(arg) 157 { 158 LstFastAppend(lst,aux,arg); 159 } 160 else 161 { 162 Error(BParser::Unparse(branch)+ 163 I2(BText(" is not a ") + gra->Name() + " object.", 164 BText(" no es un objeto de tipo ") + gra->Name())); 165 DESTROY(lst); 166 break; 167 } 145 BInt n = numParam; 146 for(BInt i=0; i<n; i++) 147 { 148 BInt j = Minimum(i, numParam-1); 149 BGrammar* gra = graParam[j]; 150 assert(gra); 151 List* branch = Branch(tre,i+1); 152 assert(branch); 153 BSyntaxObject* arg = gra->EvaluateTree(branch); 154 if(arg && ((gra==GraAnything()) || (arg->Grammar()==gra))) 155 { 156 LstFastAppend(lst,aux,arg); 157 } 158 else 159 { 160 Error(BParser::Unparse(branch)+ 161 I2(BText(" is not a ") + gra->Name() + " object.", 162 BText(" no es un objeto de tipo ") + gra->Name())); 163 DESTROY(lst); 164 return; 168 165 } 169 166 } … … 519 516 { 520 517 static BText _name_ = "Group"; 521 static BGrammar* graParam[ 2] =518 static BGrammar* graParam[3] = 522 519 { 523 520 GraText(), 524 GraSet() 521 GraSet(), 522 GraAnything() 525 523 }; 526 BSet args; BSpecialFunction::GetArg(args, tre, graParam, 2);527 524 BSyntaxObject* result = NIL; 528 BSyntaxObject* uTxt = NIL; 529 BSyntaxObject* uSet = NIL; 530 if(gra==GraAnything()) 531 { 532 Error(I2("Cannot eval Group returning an object of type Anything.", 533 "No se puede evaluar Group para devolver un objeto de tipo Anything.")); 534 } 535 else 536 { 537 if(args.Card()>=2) 538 { 539 uTxt = args[1]; 540 uSet = args[2]; 541 542 if(uTxt && uSet) 543 { 525 526 BInt nb = BSpecialFunction::NumBranches(tre); 527 BSet args; 528 if(BSpecialFunction::TestNumArg(_name_, 2, nb, 3)) 529 { 530 BSpecialFunction::GetArg(args, tre, graParam, nb); 531 } 532 if(args.Card()==nb) 533 { 534 BSyntaxObject* uTxt = NIL; 535 BSyntaxObject* uSet = NIL; 536 if(gra==GraAnything()) 537 { 538 Error(I2("Cannot eval Group returning an object of type Anything.", 539 "No se puede evaluar Group para devolver un objeto de tipo Anything.")); 540 } 541 else 542 { 543 uTxt = args[1]; 544 uSet = args[2]; 545 if(uTxt && uSet) 546 { 544 547 BSet& set = Set(uSet); 545 BText txt= uTxt->Dump();546 txt = txt.SubString(1,txt.Length()-2);547 BStandardOperator* ope = (BStandardOperator*)gra->FindOperator(txt);548 if(ope)549 {550 if(set.Card()==0)548 BText txt = uTxt->Dump(); 549 txt = txt.SubString(1,txt.Length()-2); 550 BStandardOperator* ope = (BStandardOperator*)gra->FindOperator(txt); 551 if(ope) 552 { 553 if(set.Card()==0) 551 554 { 552 if( args.Card()==3)555 if(nb==3) 553 556 { 554 result = args[3]; 557 if(gra==args[3]->Grammar()) { result = gra->New("",args[3]); } 558 else 559 { 560 Error(I2("Group default value type should be ", 561 "El valor por defecto de Group debería ser de tipo ")+gra->Name()+ 562 I2(" instead of "," en lugar de ")+args[3]->Grammar()->Name()); 563 } 555 564 } 556 565 else … … 558 567 Error(I2("Cannot evaluate Group over empty set without " 559 568 "a default value.", 560 "No sepuede evaluar Group sobre un conjunto vacío "569 "No se puede evaluar Group sobre un conjunto vacío " 561 570 "sin valor por defecto.")); 562 571 } … … 564 573 else 565 574 { 566 BBool ok = BTRUE;575 BBool ok = BTRUE; 567 576 BGrammar* g; 568 for(BInt n=1; ok&&(n<=set.Card()); n++)577 for(BInt n=1; ok&&(n<=set.Card()); n++) 569 578 { 570 579 g = set[n]->Grammar(); 571 if((gra!=GraAnything()) &&572 !(ok = (g==gra)))580 if((gra!=GraAnything()) && 581 !(ok = (g==gra))) 573 582 { 574 Error(I2("An element for Group function is not an"575 " object of type ",576 "Algún elemento para la funcion Group no"583 Error(I2("An element for Group function is not an" 584 " object of type ", 585 "Algún elemento para la funcion Group no" 577 586 " es un objeto de tipo ")+ gra->Name()+":\n"+ 578 587 set[n]->LexInfo()); 579 }580 }581 if(ok)588 } 589 } 590 if(ok) 582 591 { 583 if(set.Card()==1)592 if(set.Card()==1) 584 593 { 585 result = gra->New("",set[1]);594 result = gra->New("",set[1]); 586 595 //result = set[1]; 587 }596 } 588 597 else 589 598 { … … 591 600 BList* arg = Set(args[2]).ToReversedList(); 592 601 //Std(BText("\nGroup(")+uTxt->Dump()+",[["+set.Name()+"]])"); 593 result = ope->Evaluator(arg);594 }595 }596 }597 }598 else599 {600 Error(BText("Group : ") +txt +601 I2(" is not a " + gra->Name() + " operator.",602 " no es un operador de tipo " + gra->Name()));603 }604 }602 result = ope->Evaluator(arg); 603 } 604 } 605 } 606 } 607 else 608 { 609 Error(BText("Group : ") +txt + 610 I2(" is not a " + gra->Name() + " operator.", 611 " no es un operador de tipo " + gra->Name())); 612 } 613 } 605 614 } 606 615 } … … 1998 2007 unb = (BUserNameBlock*)result; 1999 2008 } 2000 if(!unb || (unb->Contens().Class()!=cls)) 2009 const BClass* unbCls = (!unb)?NULL:unb->Contens().Class(); 2010 if(!unb || !unbCls->InheritesFrom(cls)) 2001 2011 { 2002 2012 errMsg = I2("It was expected an instance of Class ", -
tol/btol/bgrammar/tol_bclass.h
r0d63276 r0e767dc 34 34 class TOL_API BMemberOwner; 35 35 class TOL_API BClass; 36 class TOL_API BStruct; 36 37 struct TOL_API BMbrNum; 37 38 … … 63 64 int position_; //Appearing order 64 65 }; 66 65 67 66 68 //-------------------------------------------------------------------- … … 83 85 BSyntaxObject* static_; //!< Store for Class static member or method 84 86 BText description_; //!< Store for Class member description 87 BGrammar* type_; 88 BStruct* struct_; 89 BClass* class_; 85 90 public: 86 91 // Constructors and destructors: bgrammar\class.cpp … … 102 107 int BuildMethod(); 103 108 int BuildStatic(); 109 int BuildType(); 110 int BuildAll(); 104 111 BText Dump () const; 105 112 void PutDescription(const BText& desc); … … 246 253 bool DestroyInstance(BNameBlock* instance); 247 254 //! Evaluates a parsed tree with a Class declaration 248 static BClass* PredeclareClass(const BText&name, BClass*&old, bool &ok); 249 static BClass* PredeclareClass(const BText&name); 255 static BClass* GetClassIfExist(const BText& name); 256 static BClass* PredeclareClassIfNeeded(const BText& name); 257 static BClass* PredeclareNewClass(const BText&name, BClass*&old, bool &ok); 258 static BClass* PredeclareNewClass(const BText&name); 250 259 static BSyntaxObject* Evaluate(const List* tree); 251 260 BSyntaxObject* FindMethod(const BText& memberName, bool fullAccess) const;
Note: See TracChangeset
for help on using the changeset viewer.
