/// <summary> /// Mappings to the specified Argument. /// </summary> /// <param name="name">The name.</param> /// <returns></returns> public ArgumentExpression MappingArgument(string name) { Contract.Require.That(name, Is.Not.Null & Is.Not.Empty).When("retrieving name argument in MappingArgument method"); //if (parentConfiguration == null) //{ // argumentExpression = new ArgumentExpression(builder); // parentConfiguration = builder.RegisterConfiguration(); // argumentExpression.parentConfiguration = parentConfiguration; //} //if (argumentExpression == null) //{ // argumentExpression = new ArgumentExpression(builder); // argumentExpression.parentConfiguration = parentConfiguration; //} //currentArgument = new MutableConfiguration(ConfigConstants.ELEMENT_ARGUMENT, name); //currentArgument.CreateAttribute(ConfigConstants.ATTRIBUTE_ARGUMENTNAME, name); //parentConfiguration.Children.Add(currentSubMap); MutableConfiguration configArgument = new MutableConfiguration(ConfigConstants.ELEMENT_ARGUMENT, name); configArgument.CreateAttribute(ConfigConstants.ATTRIBUTE_ARGUMENTNAME, name); builder.CurrentConfiguration.Children.Add(configArgument); ArgumentExpression argumentExpression = new ArgumentExpression(builder, parentConfiguration, configArgument); return argumentExpression; }
//Expressions #region Visit(ArgumentExpression node, Object obj) public override Object Visit(ArgumentExpression node, Object obj) { ArgumentExpression clonedArgumentExpression = new ArgumentExpression((Expression)node.Argument.Accept(this, obj), node.Location); clonedArgumentExpression.ExpressionType = node.ExpressionType.CloneType(this.typeVariableMappings, this.typeExpresionVariableMapping); return(clonedArgumentExpression); }
///////////////////////////////////////////////////////////////////////////// private object EvalArgumentConvert( ArgumentExpression arg ) { // ****** Type castToType = arg.ExpressionCastType; object value = ExecuteMacro( arg.Name, (MacroExpression) arg.Expression ); // ****** // // HAVE TO CAST value // /* implicit operator / explicit operator on a class IConvertible Convert class - use in arguments instead of our code */ try { value = Arguments.ChangeType( value, castToType ); } catch ( Exception ex ) { ThreadContext.MacroError( ex.Message ); } // ****** return value; }
// Expressions #region Visit(ArgumentExpression node, Object obj) public override Object Visit(ArgumentExpression node, Object obj) { int indent = Convert.ToInt32(obj); this.printIndentation(indent); this.output.WriteLine("Argument [{0}:{1}]", node.Location.Line, node.Location.Column); return(node.Argument.Accept(this, indent + 1)); }
public override object Visit(ArgumentExpression node, object obj) { if (node.Location == ((AstNode)obj).Location || found) { found = true; return(this.table); } return(base.Visit(node, obj)); }
/// <summary> /// Visits an element of type <see cref="ArgumentExpression" />. /// </summary> /// <param name="expression">The <see cref="ArgumentExpression" /> instance that should be visited.</param> protected internal override void VisitArgumentExpression(ArgumentExpression expression) { if (expression.RefKind == RefKind.None) base.VisitArgumentExpression(expression); else { ++_writeContext; base.VisitArgumentExpression(expression); --_writeContext; } }
// --- #region Visit(ArgumentExpression node, Object obj) public override Object Visit(ArgumentExpression node, Object obj) { Object aux = null; node.Argument.LeftExpression = node.LeftExpression; if ((aux = node.Argument.Accept(this, false)) is SingleIdentifierExpression) { node.Argument = (SingleIdentifierExpression)aux; } return(null); }
public override Ust VisitArgument(ArgumentSyntax node) { var result = (Expression)VisitAndReturnNullIfError(node.Expression); if (!node.RefKindKeyword.IsKind(SyntaxKind.None)) { InOutModifierLiteral modifierLiteral = new InOutModifierLiteral( node.RefKindKeyword.IsKind(SyntaxKind.OutKeyword) ? InOutModifier.Out : InOutModifier.InOut, node.RefKindKeyword.GetTextSpan()); result = new ArgumentExpression(modifierLiteral, result, node.GetTextSpan()); } return(result); }
static void GetSemanticsFrom(FunctionExpression mainFunction, List <StructExpression> semanticCollection, ref List <StructExpression> semantics) { // Input ArgumentExpression functionArgument = mainFunction.ConstituentSymbols[3] as ArgumentExpression; if (functionArgument.ConstituentSymbols.Count != 2) { throw new ArgumentOutOfRangeException("Argument expression for " + mainFunction.Name); } TextPart inputSemanticType = functionArgument.ConstituentSymbols[0] as TextPart; if (inputSemanticType != null) { var result = semanticCollection.Find(s => s.Name == inputSemanticType.TextValue); if (result == null) { throw new ArgumentNullException("\"" + inputSemanticType.TextValue + "\" semantic"); } semantics = new List <StructExpression>(); semantics.Add(result); } else { throw new ArgumentNullException("Input semantic for " + mainFunction.Name); } // Output TextPart outputSemanticType = mainFunction.ConstituentSymbols[0] as TextPart; if (outputSemanticType != null && outputSemanticType.TextValue != "float4") { var result = semanticCollection.Find(s => s.Name == outputSemanticType.TextValue); if (result == null) { throw new ArgumentNullException("\"" + outputSemanticType.TextValue + "\" semantic"); } semantics.Add(result); } }
// Expressions #region Visit(ArgumentExpression node, Object obj) public override Object Visit(ArgumentExpression node, Object obj) { return(node.Argument.Accept(this, obj)); }
// Expressions public abstract Object Visit(ArgumentExpression node, Object obj);
private void Format_Argument_Expression(StringBuilder sb, ArgumentExpression expression) { string modifierText = string.Join(" ", FormatterUtility.GetModifiersFromEnum(expression.Modifiers).ToArray()); if (string.IsNullOrEmpty(modifierText) == false) sb.Append(modifierText).Append(" "); sb.Append(FormatExpression(expression.Expression)); }
public virtual T Visit(ArgumentExpression argumentExpression) { return(VisitChildren(argumentExpression)); }
///////////////////////////////////////////////////////////////////////////// private object EvalArgumentConstant( ArgumentExpression arg ) { return arg.ConstantValue; }
public override Expression Parse(Parser parser) { parser.Consume(); if (!parser.Match(TokenType.Identifier)) { throw new ParsingException(string.Format("Expected identifier, found: {0}", parser.Lookahead.Type)); } var funcExpression = new FuncDeclarationExpression(); funcExpression.Name = parser.Lookahead.Value; if (funcExpression.Name == "main") { funcExpression.IsMain = true; } parser.Consume(); if (!parser.Match(TokenType.Left_Paren)) { throw new ParsingException(string.Format("Expected opening parentheses, found: {0}", parser.Lookahead.Type)); } var nextToken = parser.Peek(1); if (nextToken.Type != TokenType.Right_Paren) { var arguments = new List <ArgumentExpression>(); do { parser.Consume(); if (!parser.Match(TokenType.Identifier)) { throw new ParsingException(string.Format("Expected identifier, found: {0}", parser.Lookahead.Type)); } var argumentExpression = new ArgumentExpression(); argumentExpression.Identifier = parser.Lookahead.Value; parser.Consume(); if (!parser.Match(TokenType.Colon)) { throw new ParsingException(string.Format("Expected colon, found: {0}", parser.Lookahead.Type)); } parser.Consume(); if (!parser.Match(TokenType.Identifier)) { throw new ParsingException(string.Format("Expected type identifier, found: {0}", parser.Lookahead.Type)); } argumentExpression.Type = GetArgumentType(parser.Lookahead); arguments.Add(argumentExpression); parser.Consume(); }while (parser.Match(TokenType.Comma)); funcExpression.Arguments = arguments; } else { parser.Consume(); } if (!parser.Match(TokenType.Right_Paren)) { throw new ParsingException(string.Format("Expected closing parentheses, found: {0}", parser.Lookahead.Type)); } parser.Consume(); if (!parser.Match(TokenType.Left_Curly_Bracket)) { throw new ParsingException(string.Format("Expected opening bracket, found: {0}", parser.Lookahead.Type)); } parser.Consume(); if (!parser.Match(TokenType.Right_Curly_Bracket)) { funcExpression.Body = parser.ParseStatements(TokenType.Right_Curly_Bracket); } if (!parser.Match(TokenType.Right_Curly_Bracket)) { throw new ParsingException(string.Format("Expected closing bracket, found: {0}", parser.Lookahead.Type)); } parser.Consume(); return(funcExpression); }
///////////////////////////////////////////////////////////////////////////// private object EvalArgumentExpression( ArgumentExpression arg ) { return ExecuteMacro( arg.Name, (MacroExpression) arg.Expression ); }
protected internal override void VisitArgumentExpression(ArgumentExpression expression) { Visit(expression.Expression); }
protected internal override void VisitArgumentExpression(ArgumentExpression expression) { switch (expression.RefKind) { case RefKind.None: break; case RefKind.Ref: _writer.Append("ref "); break; case RefKind.Out: _writer.Append("out "); break; default: throw new ArgumentOutOfRangeException(); } Visit(expression.Expression); }
/// <summary> /// Visits an element of type <see cref="ArgumentExpression" />. /// </summary> /// <param name="expression">The <see cref="ArgumentExpression" /> instance that should be visited.</param> protected internal virtual void VisitArgumentExpression(ArgumentExpression expression) { DefaultVisit(expression); }
// Protected Methods protected override IPhpValue VisitArgumentExpression(ArgumentExpression src) { return(PhpVariableExpression.MakeLocal(src.Name, true)); }
///////////////////////////////////////////////////////////////////////////// private string DumpArgumentExpression( ArgumentExpression arg ) { return Process( arg.Expression ); }
///////////////////////////////////////////////////////////////////////////// private string DumpArgumentConvert( ArgumentExpression arg ) { // ****** string typeName = arg.ExpressionCastType.Name; string value = Process( arg.Expression ); // ****** return string.Format( " ({0}) {1}", typeName, value ); }
static void FunctionProcessor(StringBuilder stringBuilder, FunctionExpression expression, ShaderMetadata metadata) { // Write type stringBuilder.Append(expression.ConstituentSymbols[0].ToString()); // Write name stringBuilder.Append(" "); stringBuilder.Append(expression.ConstituentSymbols[1].ToString()); // Begin arguments stringBuilder.Append("("); // Write arguments ArgumentExpression argumentExpression = expression.ConstituentSymbols[3] as ArgumentExpression; if (argumentExpression != null && argumentExpression.ConstituentSymbols.Count > 0) { for (int i = 0; i < argumentExpression.ConstituentSymbols.Count; i += 3) { // Write type stringBuilder.Append(argumentExpression.ConstituentSymbols[i].ToString()); // Write name stringBuilder.Append(" "); stringBuilder.Append(argumentExpression.ConstituentSymbols[i + 1].ToString()); if (i + 3 < argumentExpression.ConstituentSymbols.Count) { stringBuilder.Append(", "); } } } // End arguments stringBuilder.Append(")"); // Checking has return semantic for entry point function only Colon doubleDotExpression = expression.ConstituentSymbols[5] as Colon; if (doubleDotExpression != null && metadata.EntryPoint == expression) { stringBuilder.Append(" : "); string returnSemantic = expression.ConstituentSymbols[6].ToString(); if (returnSemantic.StartsWith("POSITION", StringComparison.InvariantCulture)) { stringBuilder.Append(returnSemantic.Replace("POSITION", "SV_POSITION")); } if (returnSemantic.StartsWith("COLOR", StringComparison.InvariantCulture)) { stringBuilder.Append(returnSemantic.Replace("COLOR", "SV_TARGET")); } } // Begin statement block stringBuilder.Append(Environment.NewLine); stringBuilder.Append("{"); // Write statement block StatementBlockExpression statementBlockExpression = doubleDotExpression == null ? expression.ConstituentSymbols[6] as StatementBlockExpression : expression.ConstituentSymbols[8] as StatementBlockExpression; StatementBlockProcessor(stringBuilder, statementBlockExpression, metadata, 1); // End statement block stringBuilder.Append(Environment.NewLine); stringBuilder.Append("}"); }
///////////////////////////////////////////////////////////////////////////// private string DumpArgumentConstant( ArgumentExpression arg ) { // ****** string value = string.Empty; string typeName = string.Empty; // ****** if( null == arg.ConstantValue ) { value = "object"; typeName = "null"; } else { value = arg.ConstantValue.ToString(); typeName = arg.ConstantValueType.Name; } // ****** return string.Format( " ({0}) {1}", typeName, value ); }