Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- compile: aSourceCode where: anOrderedCollection
- (anOrderedCollection size = (self argumentsInMethod: aSourceCode) size)
- ifFalse: [
- ^self error: 'Can not compile method, number of arguments is not equal to the number of constraints!'.
- ] ifTrue: [
- |fixedSorceCode lines|
- lines := aSourceCode subStrings: '
- '.
- fixedSorceCode := (lines at: 1),'
- '.
- ((lines size > 1) and: [((lines at: 2) at: 1) = $|])
- ifFalse: [
- 1 to: (anOrderedCollection size) do: [:i |
- ((anOrderedCollection at: i) = nil)
- ifFalse: [
- fixedSorceCode := fixedSorceCode,'(', ((self argumentsInMethod: aSourceCode) at: i),
- ' isKindOf: ', ((anOrderedCollection at: i)), ')',
- ' ifFalse: [
- ^self error: ''Type mismatch! Argument ', (i printString) ,
- ' should be ', ((anOrderedCollection at: i)), '''
- ].
- '
- ]
- ].
- 2 to: (lines size) do: [:i | fixedSorceCode := fixedSorceCode , (lines at: i), '
- '].
- ] ifTrue: [
- fixedSorceCode := fixedSorceCode, (lines at: 2),'
- '.
- 1 to: (anOrderedCollection size) do: [:i |
- ((anOrderedCollection at: i) = nil)
- ifFalse: [
- fixedSorceCode := fixedSorceCode,'(', ((self argumentsInMethod: aSourceCode) at: i),
- ' isKindOf: ', ((anOrderedCollection at: i)), ')',
- ' ifFalse: [
- ^self error: ''Type mismatch! Argument ', (i printString) ,
- ' should be ', ((anOrderedCollection at: i)), '''
- ].
- '
- ]
- ].
- 3 to: (lines size) do: [:i | fixedSorceCode := fixedSorceCode , (lines at: i), '
- '].
- ].
- self compile: fixedSorceCode.
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement