public static Expression CreateCallableFromMacroBody(BooCodeBuilder builder, MacroStatement macro)
        {
            // create closure for macro's body or null
            Expression macroBody = new NullLiteralExpression();
            if (macro.Block.Statements.Count > 0)
            {
                var callableExpr = new BlockExpression {Body = macro.Block};
                callableExpr.Parameters.Add(
                    new ParameterDeclaration("OutputStream",
                                             builder.CreateTypeReference(typeof(TextWriter))));

                macroBody = callableExpr;
            }
            return macroBody;
        }
        override public object Clone()
        {
            NullLiteralExpression clone = new NullLiteralExpression();

            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);
        }
Exemple #3
0
        override public object Clone()
        {
            NullLiteralExpression clone = (NullLiteralExpression)FormatterServices.GetUninitializedObject(typeof(NullLiteralExpression));

            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);
        }
Exemple #4
0
 public override void OnNullLiteralExpression(NullLiteralExpression node)
 {
     BindExpressionType(node, Null.Default);
 }
Exemple #5
0
	protected NullLiteralExpression  null_literal() //throws RecognitionException, TokenStreamException
{
		NullLiteralExpression e;
		
		IToken  t = null;
		e = null;
		
		try {      // for error handling
			t = LT(1);
			match(NULL);
			if (0==inputState.guessing)
			{
				e = new NullLiteralExpression(ToLexicalInfo(t));
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "null_literal");
				recover(ex,tokenSet_44_);
			}
			else
			{
				throw ex;
			}
		}
		return e;
	}
Exemple #6
0
 public override void OnNullLiteralExpression(NullLiteralExpression node)
 {
     _il.Emit(OpCodes.Ldnull);
     PushType(null);
 }
Exemple #7
0
        //throws RecognitionException, TokenStreamException
        protected NullLiteralExpression null_literal()
        {
            NullLiteralExpression e;

            IToken  t = null;
            e = null;

            try {      // for error handling
            t = LT(1);
            match(NULL);
            if (0==inputState.guessing)
            {
                e = new NullLiteralExpression(SourceLocationFactory.ToLexicalInfo(t));
            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_36_);
            }
            else
            {
                throw ex;
            }
            }
            return e;
        }
		public override void OnNullLiteralExpression(NullLiteralExpression node)
		{
			MakeResult(NullReturnType.Instance);
		}
 public override void OnNullLiteralExpression(NullLiteralExpression node)
 {
     ReplaceWithCallToExpressionConstant(node);
 }
		public override void OnNullLiteralExpression(NullLiteralExpression node)
		{
			_expression = new CodePrimitiveExpression(null);
		}
        private bool checkSubstitution(ReferenceExpression node) {
            Match m = Regex.Match(node.ToCodeString(), @"^@_([\d\w]+?)(_)?$", RegexOptions.Compiled);
            if (m.Success){

                int idx = 0;
                var isordered = int.TryParse(m.Groups[1].Value, out idx);
                bool accomodate_to_strings = m.Groups[2].Value != "";
                Expression exp = new NullLiteralExpression();
                if (isordered){
                    idx = idx - 1;    
                    if (idx < args.Count){
                        exp = args[idx];
                    }
                }else{
                    var name = m.Groups[1].Value;
                    if(namedargs.ContainsKey(name)){
                        exp = namedargs[name];

                    }

                }
                
                if (accomodate_to_strings && (exp is ReferenceExpression))
                {
                    if (exp.ToCodeString().StartsWith("@"))
                    {
                        exp = new ReferenceExpression(exp.ToCodeString().Substring(1));
                    }
                    else
                    {
                        exp = new StringLiteralExpression(exp.ToCodeString());
                    }
                }
                node.ParentNode.Replace(node, exp);
                return true;
            }
            return false;
        }
 public override void OnNullLiteralExpression(NullLiteralExpression node)
 {
     WriteKeyword("null");
 }
 public NullLiteralExpression null_literal()
 {
     NullLiteralExpression expression = null;
     IToken token = null;
     try
     {
         token = this.LT(1);
         this.match(0x1d);
         if (base.inputState.guessing == 0)
         {
             expression = new NullLiteralExpression(ToLexicalInfo(token));
         }
     }
     catch (RecognitionException exception)
     {
         if (base.inputState.guessing != 0)
         {
             throw;
         }
         this.reportError(exception);
         this.recover(exception, tokenSet_20_);
         return expression;
     }
     return expression;
 }
		override public object Clone()
		{
		
			NullLiteralExpression clone = new NullLiteralExpression();
			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;


		}
Exemple #15
0
 public NullLiteralExpression CreateNullLiteral()
 {
     NullLiteralExpression expression = new NullLiteralExpression();
     expression.ExpressionType = Null.Default;
     return expression;
 }