Changeset 1562 for cobra/trunk/Source/Statements.cobra
- Timestamp:
- 07/30/08 21:42:37 (5 months ago)
- Files:
-
- 1 modified
-
cobra/trunk/Source/Statements.cobra (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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
