Method.st
changeset 463 447ead9f870c
parent 444 071b4f32272c
child 486 1e19564b2b5e
equal deleted inserted replaced
462:fdccb7651d2e 463:447ead9f870c
    21 
    21 
    22 Method comment:'
    22 Method comment:'
    23 COPYRIGHT (c) 1989 by Claus Gittinger
    23 COPYRIGHT (c) 1989 by Claus Gittinger
    24 	     All Rights Reserved
    24 	     All Rights Reserved
    25 
    25 
    26 $Header: /cvs/stx/stx/libbasic/Method.st,v 1.51 1995-10-24 15:59:25 cg Exp $
    26 $Header: /cvs/stx/stx/libbasic/Method.st,v 1.52 1995-10-31 14:36:06 cg Exp $
    27 '!
    27 '!
    28 
    28 
    29 !Method class methodsFor:'documentation'!
    29 !Method class methodsFor:'documentation'!
    30 
    30 
    31 copyright
    31 copyright
    42 "
    42 "
    43 !
    43 !
    44 
    44 
    45 version
    45 version
    46 "
    46 "
    47 $Header: /cvs/stx/stx/libbasic/Method.st,v 1.51 1995-10-24 15:59:25 cg Exp $
    47 $Header: /cvs/stx/stx/libbasic/Method.st,v 1.52 1995-10-31 14:36:06 cg Exp $
    48 "
    48 "
    49 !
    49 !
    50 
    50 
    51 documentation
    51 documentation
    52 "
    52 "
   842 
   842 
   843 methodArgNames
   843 methodArgNames
   844     "return a collection with the methods argument names.
   844     "return a collection with the methods argument names.
   845      Uses Parser to parse methods source and extract the names."
   845      Uses Parser to parse methods source and extract the names."
   846 
   846 
   847     ^ self parse:#parseMethodSpecification: return:#methodArgs or:nil
   847     ^ self parse:#'parseMethodSpecificationSilent:' return:#methodArgs or:nil
   848 
   848 
   849     "
   849     "
   850      (Method compiledMethodAt:#printOn:) methodArgNames
   850      (Method compiledMethodAt:#printOn:) methodArgNames
   851     "
   851     "
       
   852 
       
   853     "Modified: 31.10.1995 / 14:36:46 / cg"
   852 !
   854 !
   853 
   855 
   854 methodVarNames
   856 methodVarNames
   855     "return a collection with the methods local-variable names.
   857     "return a collection with the methods local-variable names.
   856      Uses Parser to parse methods source and extract the names."
   858      Uses Parser to parse methods source and extract the names."
   857 
   859 
   858     ^ self parse:#parseMethodArgAndVarSpecification: return:#methodVars or:nil
   860     ^ self parse:#'parseMethodArgAndVarSpecificationSilent:' return:#methodVars or:nil
   859 
   861 
   860     "
   862     "
   861      (Method compiledMethodAt:#printOn:) methodVarNames
   863      (Method compiledMethodAt:#printOn:) methodVarNames
   862     "
   864     "
       
   865 
       
   866     "Modified: 31.10.1995 / 14:36:49 / cg"
   863 !
   867 !
   864 
   868 
   865 hasPrimitiveCode
   869 hasPrimitiveCode
   866     "return true, if the method contains primitive code; false if not.
   870     "return true, if the method contains primitive code; false if not.
   867      Uses Parser to parse methods source and get the information."
   871      Uses Parser to parse methods source and get the information."
   868 
   872 
   869     ^ self parse:#parseMethod: return:#hasPrimitiveCode or:false
   873     |src|
       
   874 
       
   875     src := self source.
       
   876     src notNil ifTrue:[
       
   877 	(src includesString:'%{' ) ifFalse:[
       
   878 	    "/ cannot contain primitive code.
       
   879 	    ^ false
       
   880 	]
       
   881     ].
       
   882     ^ self parse:#'parseMethodSilent:' return:#hasPrimitiveCode or:false
   870 
   883 
   871     "
   884     "
   872      (Method compiledMethodAt:#hasPrimitiveCode) hasPrimitiveCode 
   885      (Method compiledMethodAt:#hasPrimitiveCode) hasPrimitiveCode 
   873      (Object compiledMethodAt:#at:) hasPrimitiveCode   
   886      (Object compiledMethodAt:#at:) hasPrimitiveCode   
   874      (Object compiledMethodAt:#basicAt:) hasPrimitiveCode 
   887      (Object compiledMethodAt:#basicAt:) hasPrimitiveCode 
   875     "
   888     "
       
   889 
       
   890     "Modified: 31.10.1995 / 14:43:37 / cg"
   876 !
   891 !
   877 
   892 
   878 methodArgAndVarNames
   893 methodArgAndVarNames
   879     "return a collection with the methods argument and variable names.
   894     "return a collection with the methods argument and variable names.
   880      Uses Parser to parse methods source and extract the names."
   895      Uses Parser to parse methods source and extract the names.
       
   896      Returns nil if the source is not available, or some other
       
   897      syntax/parse error occurred. For methods with no args and no vars,
       
   898      an empty collection is returned."
   881 
   899 
   882     |parser sourceString argNames varNames|
   900     |parser sourceString argNames varNames|
   883 
   901 
   884     sourceString := self source.
   902     sourceString := self source.
   885     sourceString notNil ifTrue:[
   903     sourceString notNil ifTrue:[
   886 	parser := Parser parseMethodArgAndVarSpecification:sourceString.
   904 	parser := Parser parseMethodArgAndVarSpecificationSilent:sourceString.
   887 	(parser isNil or:[parser == #Error]) ifTrue:[^ nil].
   905 	(parser isNil or:[parser == #Error]) ifTrue:[^ nil].
   888 	argNames := parser methodArgs.
   906 	argNames := parser methodArgs.
   889 	varNames := parser methodVars.
   907 	varNames := parser methodVars.
   890 	argNames isNil ifTrue:[^ varNames].
   908 	argNames isNil ifTrue:[^ varNames].
   891 	varNames isNil ifTrue:[^ argNames].
   909 	varNames isNil ifTrue:[^ argNames].