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);
        }
예제 #2
0
        public override void OnSelfLiteralExpression(SelfLiteralExpression node)
        {
            base.OnSelfLiteralExpression(node);

            if (node.IsTargetOfMethodInvocation())
            {
                OnExpression(node);
            }
        }
예제 #3
0
		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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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));
        }
예제 #7
0
파일: EmitAssembly.cs 프로젝트: hlizard/boo
		override public void OnSelfLiteralExpression(SelfLiteralExpression node)
		{
			LoadSelf(node);
		}
예제 #8
0
        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;
        }
예제 #9
0
		override public void OnSelfLiteralExpression(SelfLiteralExpression node)
		{
			ReplaceCurrentNode(CodeBuilder.CreateReference(node.LexicalInfo, ExternalEnumeratorSelf()));
		}
예제 #10
0
 public override void OnSelfLiteralExpression(SelfLiteralExpression node)
 {
     if (node.LexicalInfo != null)
         results.MapParsedNode(new MappedReferenceExpression(results, node));
     base.OnSelfLiteralExpression(node);
 }
예제 #11
0
		public override void OnSelfLiteralExpression(SelfLiteralExpression node)
		{
			_expression = new CodeThisReferenceExpression();
		}
예제 #12
0
 public override void OnSelfLiteralExpression(SelfLiteralExpression node)
 {
     WriteKeyword("self");
 }
예제 #13
0
 public SelfLiteralExpression CreateSelfReference(IType self)
 {
     SelfLiteralExpression expression = new SelfLiteralExpression();
     expression.ExpressionType = self;
     return expression;
 }
예제 #14
0
 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;
 }
예제 #15
0
        //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)
 {
 }
예제 #18
0
 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);
 }
예제 #19
0
		public override void OnSelfLiteralExpression(SelfLiteralExpression node)
		{
			if (callingClass == null)
				ClearResult();
			else
				MakeResult(callingClass.DefaultReturnType);
		}
예제 #20
0
	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;
	}
예제 #21
0
 public override void OnSelfLiteralExpression(SelfLiteralExpression node)
 {
     var entity = GetSelfEntity();
     node.Entity = entity;
     _references.Add(node);
     _referencedEntities[entity] = null;
 }
예제 #22
0
        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;
        }
예제 #23
0
		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;


		}