public object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data) { B.Constructor m = new B.Constructor(GetLexicalInfo(constructorDeclaration)); m.Modifiers = ConvertModifier(constructorDeclaration, B.TypeMemberModifiers.Private); ConvertAttributes(constructorDeclaration.Attributes, m.Attributes); if (currentType != null) { currentType.Members.Add(m); } ConvertParameters(constructorDeclaration.Parameters, m.Parameters); m.EndSourceLocation = GetEndLocation((INode)constructorDeclaration.Body ?? constructorDeclaration); m.Body = ConvertMethodBlock(constructorDeclaration.Body); ConstructorInitializer ci = constructorDeclaration.ConstructorInitializer; if (ci != null && !ci.IsNull) { B.Expression initializerBase; if (ci.ConstructorInitializerType == ConstructorInitializerType.Base) { initializerBase = new B.SuperLiteralExpression(); } else { initializerBase = new B.SelfLiteralExpression(); } B.MethodInvocationExpression initializer = new B.MethodInvocationExpression(initializerBase); ConvertExpressions(ci.Arguments, initializer.Arguments); m.Body.Insert(0, new B.ExpressionStatement(initializer)); } return(m); }
public override void OnSelfLiteralExpression(SelfLiteralExpression node) { base.OnSelfLiteralExpression(node); if (node.IsTargetOfMethodInvocation()) { OnExpression(node); } }
public void LiftCastExpressionWithSelfTarget() { var self = new SelfLiteralExpression(); var typeReference = new SimpleTypeReference("T"); Expression cast = new TryCastExpression(self, typeReference); var parameter = ParameterDeclaration.Lift(cast); Assert.AreEqual("self", parameter.Name); Assert.IsTrue(typeReference.Matches(parameter.Type)); Assert.AreNotSame(typeReference, parameter.Type); }
override public object Clone() { SelfLiteralExpression clone = (SelfLiteralExpression)FormatterServices.GetUninitializedObject(typeof(SelfLiteralExpression)); clone._lexicalInfo = _lexicalInfo; clone._endSourceLocation = _endSourceLocation; clone._documentation = _documentation; clone._entity = _entity; if (_annotations != null) { clone._annotations = (Hashtable)_annotations.Clone(); } clone._expressionType = _expressionType; return(clone); }
override public object Clone() { SelfLiteralExpression clone = new SelfLiteralExpression(); clone._lexicalInfo = _lexicalInfo; clone._endSourceLocation = _endSourceLocation; clone._documentation = _documentation; clone._isSynthetic = _isSynthetic; clone._entity = _entity; if (_annotations != null) { clone._annotations = (Hashtable)_annotations.Clone(); } clone._expressionType = _expressionType; return(clone); }
public override void OnSelfLiteralExpression(SelfLiteralExpression node) { if (null == _externalEnumeratorSelf) { IType type = node.ExpressionType; _externalEnumeratorSelf = DeclareFieldInitializedFromConstructorParameter( _enumerator, _enumeratorConstructor, "self_", type); } ReplaceCurrentNode(CodeBuilder.CreateReference(node.LexicalInfo, _externalEnumeratorSelf)); }
override public void OnSelfLiteralExpression(SelfLiteralExpression node) { LoadSelf(node); }
public override void OnSelfLiteralExpression(SelfLiteralExpression node) { if (null == _currentMethod) { Error(node, CompilerErrorFactory.SelfOutsideMethod(node)); return; } if (_currentMethod.IsStatic) { if (NodeType.MemberReferenceExpression != node.ParentNode.NodeType) { // if we are inside a MemberReferenceExpression // let the MemberReferenceExpression deal with it // as it can provide a better message Error(CompilerErrorFactory.SelfIsNotValidInStaticMember(node)); } } node.Entity = _currentMethod; node.ExpressionType = _currentMethod.DeclaringType; }
override public void OnSelfLiteralExpression(SelfLiteralExpression node) { ReplaceCurrentNode(CodeBuilder.CreateReference(node.LexicalInfo, ExternalEnumeratorSelf())); }
public override void OnSelfLiteralExpression(SelfLiteralExpression node) { if (node.LexicalInfo != null) results.MapParsedNode(new MappedReferenceExpression(results, node)); base.OnSelfLiteralExpression(node); }
public override void OnSelfLiteralExpression(SelfLiteralExpression node) { _expression = new CodeThisReferenceExpression(); }
public override void OnSelfLiteralExpression(SelfLiteralExpression node) { WriteKeyword("self"); }
public SelfLiteralExpression CreateSelfReference(IType self) { SelfLiteralExpression expression = new SelfLiteralExpression(); expression.ExpressionType = self; return expression; }
public SelfLiteralExpression self_literal() { SelfLiteralExpression expression = null; IToken token = null; try { token = this.LT(1); this.match(40); if (base.inputState.guessing == 0) { expression = new SelfLiteralExpression(ToLexicalInfo(token)); } } catch (RecognitionException exception) { if (base.inputState.guessing != 0) { throw; } this.reportError(exception); this.recover(exception, tokenSet_20_); return expression; } return expression; }
//throws RecognitionException, TokenStreamException protected SelfLiteralExpression self_literal() { SelfLiteralExpression e; IToken t = null; e = null; try { // for error handling t = LT(1); match(SELF); if (0==inputState.guessing) { e = new SelfLiteralExpression(SourceLocationFactory.ToLexicalInfo(t)); } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex); recover(ex,tokenSet_36_); } else { throw ex; } } return e; }
public object VisitConstructorDeclaration(ConstructorDeclaration constructorDeclaration, object data) { B.Constructor m = new B.Constructor(GetLexicalInfo(constructorDeclaration)); m.Modifiers = ConvertModifier(constructorDeclaration, B.TypeMemberModifiers.Private); ConvertAttributes(constructorDeclaration.Attributes, m.Attributes); if (currentType != null) currentType.Members.Add(m); ConvertParameters(constructorDeclaration.Parameters, m.Parameters); m.EndSourceLocation = GetEndLocation((INode)constructorDeclaration.Body ?? constructorDeclaration); m.Body = ConvertMethodBlock(constructorDeclaration.Body); ConstructorInitializer ci = constructorDeclaration.ConstructorInitializer; if (ci != null && !ci.IsNull) { B.Expression initializerBase; if (ci.ConstructorInitializerType == ConstructorInitializerType.Base) initializerBase = new B.SuperLiteralExpression(); else initializerBase = new B.SelfLiteralExpression(); B.MethodInvocationExpression initializer = new B.MethodInvocationExpression(initializerBase); ConvertExpressions(ci.Arguments, initializer.Arguments); m.Body.Insert(0, new B.ExpressionStatement(initializer)); } return m; }
public MappedReferenceExpression(CompileResults results, SelfLiteralExpression node) : base(results, node, "self".Length) { }
public override void OnSelfLiteralExpression(SelfLiteralExpression node) { _il.Emit(OpCodes.Ldarg_0); if (node.ExpressionType.IsValueType) { _il.Emit(OpCodes.Ldobj, GetSystemType(node.ExpressionType)); } PushType(node.ExpressionType); }
public override void OnSelfLiteralExpression(SelfLiteralExpression node) { if (callingClass == null) ClearResult(); else MakeResult(callingClass.DefaultReturnType); }
protected SelfLiteralExpression self_literal() //throws RecognitionException, TokenStreamException { SelfLiteralExpression e; IToken t = null; e = null; try { // for error handling t = LT(1); match(SELF); if (0==inputState.guessing) { e = new SelfLiteralExpression(ToLexicalInfo(t)); } } catch (RecognitionException ex) { if (0 == inputState.guessing) { reportError(ex, "self_literal"); recover(ex,tokenSet_44_); } else { throw ex; } } return e; }
public override void OnSelfLiteralExpression(SelfLiteralExpression node) { var entity = GetSelfEntity(); node.Entity = entity; _references.Add(node); _referencedEntities[entity] = null; }
protected Expression CreateMemberReferenceTarget(Node sourceNode, IMember member) { Expression target = null; if (member.IsStatic) { target = CodeBuilder.CreateReference(sourceNode.LexicalInfo, member.DeclaringType); } else { //check if found entity can't possibly be a member of self: if (member.DeclaringType != CurrentType && !(CurrentType.IsSubclassOf(member.DeclaringType))) { Error(CompilerErrorFactory.InstanceRequired(sourceNode, member)); } target = new SelfLiteralExpression(sourceNode.LexicalInfo); } BindExpressionType(target, member.DeclaringType); return target; }
override public object Clone() { SelfLiteralExpression clone = new SelfLiteralExpression(); clone._lexicalInfo = _lexicalInfo; clone._endSourceLocation = _endSourceLocation; clone._documentation = _documentation; clone._isSynthetic = _isSynthetic; clone._entity = _entity; if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone(); clone._expressionType = _expressionType; return clone; }