override public object Clone() { RaiseStatement clone = (RaiseStatement)FormatterServices.GetUninitializedObject(typeof(RaiseStatement)); clone._lexicalInfo = _lexicalInfo; clone._endSourceLocation = _endSourceLocation; clone._documentation = _documentation; clone._entity = _entity; if (_annotations != null) { clone._annotations = (Hashtable)_annotations.Clone(); } if (null != _modifier) { clone._modifier = _modifier.Clone() as StatementModifier; clone._modifier.InitializeParent(clone); } if (null != _exception) { clone._exception = _exception.Clone() as Expression; clone._exception.InitializeParent(clone); } return(clone); }
override public object Clone() { RaiseStatement clone = new RaiseStatement(); clone._lexicalInfo = _lexicalInfo; clone._endSourceLocation = _endSourceLocation; clone._documentation = _documentation; clone._isSynthetic = _isSynthetic; clone._entity = _entity; if (_annotations != null) { clone._annotations = (Hashtable)_annotations.Clone(); } if (null != _modifier) { clone._modifier = _modifier.Clone() as StatementModifier; clone._modifier.InitializeParent(clone); } if (null != _exception) { clone._exception = _exception.Clone() as Expression; clone._exception.InitializeParent(clone); } return(clone); }
public override Statement Expand(MacroStatement macro) { if (macro.Arguments.Count == 0) throw new MonoRailException("Section must be called with a name"); MacroStatement component = GetParentComponent(macro); componentContextName = ComponentNaming.GetComponentContextName(component); componentVariableName = ComponentNaming.GetComponentNameFor(component); string sectionName = macro.Arguments[0].ToString(); Block block = new Block(); //if (!Component.SupportsSection(section.Name)) // throw new ViewComponentException( String.Format("The section '{0}' is not supported by the ViewComponent '{1}'", section.Name, ComponentName)); MethodInvocationExpression supportsSection = new MethodInvocationExpression( AstUtil.CreateReferenceExpression(componentVariableName + ".SupportsSection"), new StringLiteralExpression(sectionName)); //create the new exception RaiseStatement raiseSectionNotSupportted = new RaiseStatement( new MethodInvocationExpression( AstUtil.CreateReferenceExpression(typeof(ViewComponentException).FullName), new StringLiteralExpression( String.Format("The section '{0}' is not supported by the ViewComponent '{1}'", sectionName, component.Arguments[0].ToString()) ) )); Block trueBlock = new Block(); trueBlock.Add(raiseSectionNotSupportted); IfStatement ifSectionNotSupported = new IfStatement(new UnaryExpression(UnaryOperatorType.LogicalNot, supportsSection), trueBlock, null); block.Add(ifSectionNotSupported); //componentContext.RegisterSection(sectionName); MethodInvocationExpression mie = new MethodInvocationExpression( new MemberReferenceExpression(new ReferenceExpression(componentContextName), "RegisterSection"), new StringLiteralExpression(sectionName), CodeBuilderHelper.CreateCallableFromMacroBody(CodeBuilder, macro)); block.Add(mie); IDictionary sections = (IDictionary) component["sections"]; if (sections == null) { component["sections"] = sections = new Hashtable(); } sections.Add(sectionName, block); return null; }
public override void LeaveRaiseStatement(RaiseStatement node) { if (node.Exception == null) return; var exceptionType = GetExpressionType(node.Exception); if (IsError(exceptionType)) return; if (TypeSystemServices.StringType == exceptionType) { node.Exception = CodeBuilder.CreateConstructorInvocation( node.Exception.LexicalInfo, MethodCache.Exception_StringConstructor, node.Exception); } else if (!TypeSystemServices.IsValidException(exceptionType)) { Error(CompilerErrorFactory.InvalidRaiseArgument(node.Exception, exceptionType)); } }
protected RaiseStatement raise_stmt() //throws RecognitionException, TokenStreamException { RaiseStatement s; IToken t = null; s = null; Expression e = null; try { // for error handling t = LT(1); match(RAISE); { switch ( LA(1) ) { case ESEPARATOR: case CAST: case CHAR: case FALSE: case NOT: case NULL: case SELF: case SUPER: case THEN: case TRUE: case TYPEOF: case TRIPLE_QUOTED_STRING: case LPAREN: case DOUBLE_QUOTED_STRING: case SINGLE_QUOTED_STRING: case ID: case MULTIPLY: case LBRACK: case SPLICE_BEGIN: case DOT: case LBRACE: case QQ_BEGIN: case SUBTRACT: case LONG: case INCREMENT: case DECREMENT: case ONES_COMPLEMENT: case INT: case BACKTICK_QUOTED_STRING: case RE_LITERAL: case DOUBLE: case FLOAT: case TIMESPAN: { e=expression(); break; } case EOL: case IF: case UNLESS: case WHILE: case EOS: case RBRACE: case QQ_END: { break; } default: { throw new NoViableAltException(LT(1), getFilename()); } } } if (0==inputState.guessing) { s = new RaiseStatement(ToLexicalInfo(t)); s.Exception = e; } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex, "raise_stmt"); recover(ex,tokenSet_90_); } else { throw ex; } } return s; }
public override void OnRaiseStatement(RaiseStatement node) { EmitDebugInfo(node); if (node.Exception == null) { _il.Emit(OpCodes.Rethrow); } else { Visit(node.Exception); PopType(); _il.Emit(OpCodes.Throw); } }
public override void LeaveRaiseStatement(RaiseStatement node) { if (node.Exception != null) return; if (_state.InExceptionHandler) return; Error(CompilerErrorFactory.ReRaiseOutsideExceptionHandler(node)); }
override public object Clone() { RaiseStatement clone = new RaiseStatement(); clone._lexicalInfo = _lexicalInfo; clone._endSourceLocation = _endSourceLocation; clone._documentation = _documentation; clone._isSynthetic = _isSynthetic; clone._entity = _entity; if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone(); if (null != _modifier) { clone._modifier = _modifier.Clone() as StatementModifier; clone._modifier.InitializeParent(clone); } if (null != _exception) { clone._exception = _exception.Clone() as Expression; clone._exception.InitializeParent(clone); } return clone; }
override public bool EnterRaiseStatement(RaiseStatement node) { RemoveUnreachableCode(node); return false; }
public override void LeaveRaiseStatement(RaiseStatement node) { LeaveStatement(node); }
public override void OnRaiseStatement(RaiseStatement rs) { WriteIndented(); WriteKeyword("raise "); Visit(rs.Exception); Visit(rs.Modifier); WriteLine(); }
Method CreateMethodStub(IMethod baseMethod) { Method stub = CreateMethodFromPrototype(baseMethod, TypeSystemServices.GetAccess(baseMethod) | TypeMemberModifiers.Virtual); MethodInvocationExpression x = new MethodInvocationExpression(); x.Target = new MemberReferenceExpression( new ReferenceExpression("System"), "NotImplementedException"); RaiseStatement rs = new RaiseStatement(x); rs.LexicalInfo = LexicalInfo.Empty; stub.Body.Statements.Insert(0, rs); return stub; }
public void throw_statement(Block b) { IToken token = null; try { Expression expression; token = this.LT(1); this.match(0x29); if (tokenSet_16_.member(this.LA(1)) && tokenSet_49_.member(this.LA(2))) { expression = this.expression(); } else if (!tokenSet_15_.member(this.LA(1)) || !tokenSet_20_.member(this.LA(2))) { throw new NoViableAltException(this.LT(1), this.getFilename()); } if (base.inputState.guessing == 0) { RaiseStatement statement; RaiseStatement statement1 = statement = new RaiseStatement(ToLexicalInfo(token)); statement.set_Exception(expression); b.Add(statement); } } catch (RecognitionException exception) { if (base.inputState.guessing != 0) { throw; } this.reportError(exception); this.recover(exception, tokenSet_15_); } }
public TypeMember CreateStub(IMember member) { IMethod baseMethod = (member as IMethod); if (null == baseMethod) return null; Method stub = CreateMethodFromPrototype(baseMethod, TypeMemberModifiers.Public | TypeMemberModifiers.Virtual); MethodInvocationExpression x = new MethodInvocationExpression(); x.Target = new MemberReferenceExpression( new ReferenceExpression("System"), "NotImplementedException"); RaiseStatement rs = new RaiseStatement(x); rs.LexicalInfo = LexicalInfo.Empty; stub.Body.Statements.Insert(0, rs); return stub; }