📄 strings.hhf
字号:
#print( "WARNING! str.zcpy is deprecated, use zstr.cpy instead" ) @global:zstr.cpy(z) #endmacro #macro zcat( z ); #print( "WARNING! str.zcat is deprecated, use zstr.cat instead" ) @global:zstr.cpy(z) #endmacro const validPutType :boolean[ @global:hla.sizePTypes ] := [ @global:false, // Undefined @global:true, // tBoolean //1 @global:false, // enum //2 @global:true, // tUns8, //3 @global:true, // tUns16, //4 @global:true, // tUns32, //5 @global:true, // tUns64, //6 @global:true, // tUns128, //7 @global:true, // tByte, //8 @global:true, // tWord, //9 @global:true, // tDWord, //10 @global:true, // tQWord, //11 @global:true, // tTByte, //12 @global:true, // tLWord, //13 @global:true, // tInt8, //14 @global:true, // tInt16, //15 @global:true, // tInt32, //16 @global:true, // tInt64, //17 @global:true, // tInt128, //18 @global:true, // tChar, //19 @global:false, // tWChar, //20 @global:true, // tReal32, //21 @global:true, // tReal64, //22 @global:true, // tReal80, //23 @global:false, // tReal128, //24 @global:true, // tString, //25 @global:true, // tZString, //26 @global:false, // tWString, //27 @global:true, // tCset, //28 @global:false, // tArray, //29 @global:false, // tRecord, //30 @global:false, // tUnion, //31 @global:false, // tRegEx //32 @global:true, // tClass, //33 @global:false, // tProcptr, //34 @global:false, // tThunk, //35 @global:true, // tPointer //36 @global:false, // tLabel //37 @global:false, // tProc //38 @global:false, // tMethod //39 @global:false, // tClassProc //40 @global:false, // tClassIter //41 @global:false, // tIterator //42 @global:false, // tProgram //43 @global:false, // tMacro //44 @global:false, // tText //45 @global:false, // tRegExMac //46 @global:false, // tNamespace //47 @global:false, // tSegment //48 @global:false, // tAnonRec //49 @global:false, // tAnonUnion //50 @global:false, // tVariant //51 @global:false // tError //52 ]; validPutSizeType :boolean[ @global:hla.sizePTypes ] := [ @global:false, // Undefined @global:false, // tBoolean //1 @global:false, // enum //2 @global:true, // tUns8, //3 @global:true, // tUns16, //4 @global:true, // tUns32, //5 @global:true, // tUns64, //6 @global:true, // tUns128, //7 @global:true, // tByte, //8 @global:true, // tWord, //9 @global:true, // tDWord, //10 @global:true, // tQWord, //11 @global:true, // tTByte, //12 @global:true, // tLWord, //13 @global:true, // tInt8, //14 @global:true, // tInt16, //15 @global:true, // tInt32, //16 @global:true, // tInt64, //17 @global:true, // tInt128, //18 @global:true, // tChar, //19 @global:false, // tWChar, //20 @global:true, // tReal32, //21 @global:true, // tReal64, //22 @global:true, // tReal80, //23 @global:false, // tReal128, //24 @global:true, // tString, //25 @global:true, // tZString, //26 @global:false, // tWString, //27 @global:false, // tCset, //28 @global:false, // tArray, //29 @global:false, // tRecord, //30 @global:false, // tUnion, //31 @global:false, // tRegEx //32 @global:false, // tClass, //33 @global:false, // tProcptr, //34 @global:false, // tThunk, //35 @global:true, // tPointer //36 @global:false, // tLabel //37 @global:false, // tProc //38 @global:false, // tMethod //39 @global:false, // tClassProc //40 @global:false, // tClassIter //41 @global:false, // tIterator //42 @global:false, // tProgram //43 @global:false, // tMacro //44 @global:false, // tText //45 @global:false, // tRegExMac //46 @global:false, // tNamespace //47 @global:false, // tSegment //48 @global:false, // tAnonRec //49 @global:false, // tAnonUnion //50 @global:false, // tVariant //51 @global:false // tError //52 ]; validPutSize2Type :boolean[ @global:hla.sizePTypes ] := [ @global:false, // Undefined @global:false, // tBoolean //1 @global:false, // enum //2 @global:false, // tUns8, //3 @global:false, // tUns16, //4 @global:false, // tUns32, //5 @global:false, // tUns64, //6 @global:false, // tUns128, //7 @global:false, // tByte, //8 @global:false, // tWord, //9 @global:false, // tDWord, //10 @global:false, // tQWord, //11 @global:false, // tTByte, //12 @global:false, // tLWord, //13 @global:false, // tInt8, //14 @global:false, // tInt16, //15 @global:false, // tInt32, //16 @global:false, // tInt64, //17 @global:false, // tInt128, //18 @global:false, // tChar, //19 @global:false, // tWChar, //20 @global:true, // tReal32, //21 @global:true, // tReal64, //22 @global:true, // tReal80, //23 @global:false, // tReal128, //24 @global:false, // tString, //25 @global:false, // tZString, //26 @global:false, // tWString, //27 @global:false, // tCset, //28 @global:false, // tArray, //29 @global:false, // tRecord, //30 @global:false, // tUnion, //31 @global:false, // tRegEx //32 @global:false, // tClass, //33 @global:false, // tProcptr, //34 @global:false, // tThunk, //35 @global:false, // tPointer //36 @global:false, // tLabel //37 @global:false, // tProc //38 @global:false, // tMethod //39 @global:false, // tClassProc //40 @global:false, // tClassIter //41 @global:false, // tIterator //42 @global:false, // tProgram //43 @global:false, // tMacro //44 @global:false, // tText //45 @global:false, // tRegExMac //46 @global:false, // tNamespace //47 @global:false, // tSegment //48 @global:false, // tAnonRec //49 @global:false, // tAnonUnion //50 @global:false, // tVariant //51 @global:false // tError //52 ]; putFunc :string[ @global:hla.sizePTypes ] := [ "", // Undefined "catbool", // tBoolean //1 "", // enum //2 "catu8", // tUns8, //3 "catu16", // tUns16, //4 "catu32", // tUns32, //5 "catu64", // tUns64, //6 "catu128", // tUns128, //7 "catb", // tByte, //8 "catw", // tWord, //9 "catd", // tDWord, //10 "catq", // tQWord, //11 "cattb", // tTByte, //12 "catl", // tLWord, //13 "cati8", // tInt8, //14 "cati16", // tInt16, //15 "cati32", // tInt32, //16 "cati64", // tInt64, //17 "cati128", // tInt128, //18 "catc", // tChar, //19 "", // tWChar, //20 "_cate32", // tReal32, //21 "_cate64", // tReal64, //22 "_cate80", // tReal80, //23 "", // tReal128, //24 "cats", // tString, //25 "catzs", // tZString, //26 "", // tWString, //27 "catcset", // tCset, //28 "", // tArray, //29 "", // tRecord, //30 "", // tUnion, //31 "", // tRegEx //32 "", // tClass, //33 "", // tProcptr, //34 "", // tThunk, //35 "catd", // tPointer //36 "", // tLabel //37 "", // tProc //38 "", // tMethod //39 "", // tClassProc //40 "", // tClassIter //41 "", // tIterator //42 "", // tProgram //43 "", // tMacro //44 "", // tText //45 "", // tRegExMac //46 "", // tNamespace //47 "", // tSegment //48 "", // tAnonRec //49 "", // tAnonUnion //50 "", // tVariant //51 "" // tError //52 ]; putSizeFunc :string[ @global:hla.sizePTypes ] := [ "", // Undefined "", // tBoolean //1 "", // enum //2 "catu8Size", // tUns8, //3 "catu16Size", // tUns16, //4 "catu32Size", // tUns32, //5 "catu64Size", // tUns64, //6 "catu128Size", // tUns128, //7 "cath8Size", // tByte, //8 "cath16Size", // tWord, //9 "cath32Size", // tDWord, //10 "cath64Size", // tQWord, //11 "cath80Size", // tTByte, //12 "cath128Size", // tLWord, //13 "cati8Size", // tInt8, //14 "cati16Size", // tInt16, //15 "cati32Size", // tInt32, //16 "cati64Size", // tInt64, //17 "cati128Size", // tInt128, //18 "catcSize", // tChar, //19 "", // tWChar, //20 "cate32_", // tReal32, //21 "cate64_", // tReal64, //22 "cate80_", // tReal80, //23 "", // tReal128, //24 "catsSize", // tString, //25 "catzsSize", // tZString, //26 "", // tWString, //27 "", // tCset, //28 "", // tArray, //29 "", // tRecord, //30 "", // tUnion, //31 "", // tRegEx //32 "", // tClass, //33 "", // tProcptr, //34 "", // tThunk, //35 "catdSize", // tPointer //36 "", // tLabel //37 "", // tProc //38 "", // tMethod //39 "", // tClassProc //40 "", // tClassIter //41 "", // tIterator //42 "", // tProgram //43 "", // tMacro //44 "", // tText //45 "", // tRegExMac //46 "", // tNamespace //47 "", // tSegment //48 "", // tAnonRec //49 "", // tAnonUnion //50 "", // tVariant //51 "" // tError //52 ]; putSize2Func :string[ @global:hla.sizePTypes ] := [ "", // Undefined "", // tBoolean //1 "", // enum //2 "", // tUns8, //3 "", // tUns16, //4 "", // tUns32, //5 "", // tUns64, //6 "", // tUns128, //7 "", // tByte, //8 "", // tWord, //9 "", // tDWord, //10 "", // tQWord, //11 "", // tLWord, //12 "", // tLWord, //13 "", // tInt8, //14 "", // tInt16, //15 "", // tInt32, //16 "", // tInt64, //17 "", // tInt128, //18 "", // tChar, //19 "", // tWChar, //20 "catr32pad", // tReal32, //21 "catr64pad", // tReal64, //22 "catr80pad", // tReal80, //23 "", // tReal128, //24 "", // tString, //25 "", // tZString, //26 "", // tWString, //27 "", // tCset, //28 "", // tArray, //29 "", // tRecord, //30 "", // tUnion, //31 "", // tRegEx //32 "", // tClass, //33 "", // tProcptr, //34 "", // tThunk, //35 "", // tPointer //36 "", // tLabel //37 "", // tProc //38 "", // tMethod //39 "", // tClassProc //40 "", // tClassIter //41 "", // tIterator //42 "", // tProgram //43 "", // tMacro //44 "", // tText //45 "", // tRegExMac //46 "", // tNamespace //47 "", // tSegment //48 "", // tAnonRec //49 "", // tAnonUnion //50 "", // tVariant //51 "" // tError //52 ]; // str.put macro: // (note: use global VAL objects to speed up processing: val _theParm_:string; _theDest_:string; #macro put( _destStr_, _parameters_[] ); ?@global:str._theDest_ := @string:_destStr_; push( eax ); mov( _destStr_, eax ); mov( 0, (type str.strRec [eax]).length ); mov( 0, (type byte [eax]) ); pop( eax ); ?@global:str._theParm_ :string := @string:_destStr_; #for( @global:str._theParm_ in _parameters_ ) @global:hla.put ( str, @global:str._theDest_, @eval(@global:str._theParm_) ) #endfor #endmacro // str.put2 macro: val _theParm2_:string; _theDest2_:string; #macro put2( _destStr_, _parameters_[] ):_sv_; ?@global:str._theDest2_ := @string:_destStr_; #for( @global:str._theParm2_ in _parameters_ ) @global:hla.put ( str, @global:str._theDest2_, @eval(@global:str._theParm2_) ) #endfor #endmacro readonly CmdLnDelimiters :cset; @external( "STR_CMDLNDELIMITERS" );//////////////////// TODOs //////////////////////////////////////////////// Left to implement /////////////////////////////////////////////////////////////////////////// // The following macros write "function overloading" macros // that are used to create function overloads for all the // string/pattern matching functions. // // The implementation is somewhat ugly because the HLA // macro expander copies all text between #macro and #endmacro // without any translation when recording a macro. In the // following examples, the code needs to replace certain names // within the body of the macro being generated. To accomplish this, // the following code first creates a string object that is the // macro definition (complete with injected strings) and then // expands that string as text to generate the actual macro. val parmCnt := 0; fName :string := ""; #macro strpat1( string macroName ):theMacro; ?theMacro :text := "#macro " + macroName + "( parms[] ); " "?@global:str.parmCnt := @elements( parms ); " "#if( @global:str.parmCnt = 1 ) " "@text( ""@global:str." + macroName + "1"" ) " "( " "@text( parms[0] ) " ") " "#elseif( @global:str.parmCnt = 2 ) " "@text( ""@global:str." + macroName + "2"" ) " "( " "@text( parms[0] ), " "@text( parms[1] ) " ") " "#elseif( @global:str.parmCnt = 3 ) " "@text( ""@global:str." + macroName + "3"" ) " "( " "@text( parms[0] ), " "@text( parms[1] ), " "@text( parms[2] ) " ") " "#else " "#error " "( " """Could not match parameters to the '" + macroName + "' function"" " ") " "#endif " "#endmacro "; theMacro #endmacro #macro strpat2( string macroName ):theMacro; ?theMacro :text := "#macro " + macroName + "( parms[] ); " "?@global:str.parmCnt := @elements( parms ); " "#if( @global:str.parmCnt = 2 ) " "@text( ""@global:str." + macroName + "2"" ) " "( " "@text( parms[0] ), " "@text( parms[1] ) " ") " "#elseif( @global:str.parmCnt = 3 ) " "@text( ""@global:str." + macroName + "3"" ) " "( " "@text( parms[0] ), " "@text( parms[1] ), " "@text( parms[2] ) " ") " "#elseif( @global:str.parmCnt = 4 ) " "@text( ""@global:str." + macroName + "4"" ) " "( " "@text( parms[0] ), " "@text( parms[1] ), " "@text( parms[2] ), " "@text( parms[3] ) " ") " "#else " "#error " "( " """Could not match parameters to the '" + macroName + "' function"" " ") " "#endif " "#endmacro "; theMacro #endmacro #macro strpat3( string macroName ):theMacro; ?theMacro :text := "#macro " + macroName + "( parms[] ); " "?@global:str.parmCnt := @elements( parms ); " "#if( @global:str.parmCnt = 3 ) " "@text( ""@global:str." + macroName + "3"" ) " "( " "@text( parms[0] ), " "@text( parms[1] ), " "@text( parms[2] ) " ") " "#elseif( @global:str.parmCnt = 4 ) " "@text( ""@global:str." + macroName + "4"" ) " "( " "@text( parms[0] ), " "@text( parms[1] ), " "@text( parms[2] ), " "@text( parms[3] ) " ") " "#elseif( @global:str.parmCnt = 5 ) " "@text( ""@global:str." + macroName + "5"" ) " "( " "@text( parms[0] ), " "@text( parms[1] ), " "@text( parms[2] ), " "@text( parms[3] ), " "@text( parms[4] ) " ") " "#else "
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -