Changeset 1562
- Timestamp:
- 07/30/08 21:42:37 (4 months ago)
- Location:
- cobra/trunk
- Files:
-
- 1 added
- 5 modified
-
Source/BinaryOpExpr.cobra (modified) (1 diff)
-
Source/CobraParser.cobra (modified) (1 diff)
-
Source/Expr.cobra (modified) (1 diff)
-
Source/Members.cobra (modified) (2 diffs)
-
Source/Statements.cobra (modified) (3 diffs)
-
Tests/220-delegates-etc/120-events/304-raise-protected.cobra (added)
Legend:
- Unmodified
- Added
- Removed
-
cobra/trunk/Source/BinaryOpExpr.cobra
r1557 r1562 917 917 _dotRightExpr = right to IDotRightExpr 918 918 _isImplicit = isImplicit 919 920 get dotRight as IDotRightExpr 921 """ 922 Returns .right but with the more narrow type of IDotRightExpr. 923 """ 924 return _dotRightExpr 919 925 920 926 pro isImplicit from var -
cobra/trunk/Source/CobraParser.cobra
r1560 r1562 2063 2063 token = .expect('RAISE') 2064 2064 exprs = .commaSepExprs('EOL') 2065 assert .last.which=='EOL' 2066 .undo # need EOL 2065 2067 if exprs.count == 0 2066 2068 .throwError('Expecting one or more expressions after "raise", starting with the event. If you meant to throw the currently caught exception, use "throw" instead.') -
cobra/trunk/Source/Expr.cobra
r1558 r1562 989 989 if defi inherits IType 990 990 return defi 991 else 991 else if defi inherits BoxEvent 992 return defi.handlerType 993 else 992 994 throw FallThroughException(defi) 993 995 else -
cobra/trunk/Source/Members.cobra
r1560 r1562 379 379 380 380 get defaultAccessLevel as String is override 381 return 'public'381 return if(.name.startsWith('_'), 'protected', 'public') 382 382 383 383 get englishName as String is override … … 432 432 .writeSharpAttribs(sw) 433 433 .writeSharpIsNames(sw) 434 sw.write('event ') 434 435 sw.write(.handlerType.sharpRef) 435 436 sw.write(' [.sharpName]') -
cobra/trunk/Source/Statements.cobra
r1560 r1562 1172 1172 1173 1173 var _name = '' 1174 var _eventType as IType? 1174 1175 var _exprs as List<of Expr> 1175 1176 var _definition as BoxEvent? … … 1200 1201 expr = _exprs[0] 1201 1202 if expr inherits DotExpr 1202 right = expr.right 1203 if right inherits IDotRightExpr 1204 defi = (right to dynamic).definition 1205 if defi inherits BoxEvent 1206 _definition = defi 1207 _name = defi.name 1208 else 1209 .throwError('Expecting an event to raise.') 1203 right = expr.dotRight 1204 defi = (right to dynamic).definition 1205 if defi inherits BoxEvent 1206 _definition = defi 1207 _name = defi.name 1208 _eventType = defi.handlerType 1210 1209 else 1211 assert false # should be impossible to get here since it was a dotexpr 1210 .throwError('Expecting an event to raise.') 1211 else if expr inherits IdentifierExpr # ex: raise _eventName 1212 _name = expr.name 1213 assert expr.potentialType 1214 _eventType = expr.potentialType 1212 1215 else 1213 1216 .throwError('Invalid expression for raising events. Try "raise .someEvent, args" or "throw SomeException(args)".') … … 1216 1219 base.writeSharpDef(sw) 1217 1220 name = Utils.capped(.name) 1218 sw.write('if (this.[name]!=null) this.[name](') 1221 localName = '_lh_event_[.serialNum]' 1222 sw.write('{ [_eventType.sharpRef] [localName] = this.[name]; if ([localName]!=null) [localName](') 1219 1223 sep = '' 1224 # Assuming usual argsList case is 2 args (sender, eventArgs). If have fewer than this 1225 # presume the first arg - sender ('this') - is elided 1226 # TODO: need to compare to the actual count of the parameter list instead of assuming this 1227 if _exprs.count == 2 1228 sep = 'this, ' 1220 1229 for expr in _exprs[1:] 1221 1230 sw.write(sep) 1222 1231 expr.writeSharpDef(sw, false) 1223 1232 sep = ', ' 1224 sw.write('); \n')1225 1233 sw.write('); }\n') 1234 1226 1235 1227 1236 class ReturnStmt
