private void TypeToArguments(NamedCollection <IArgumentInstance> arguments, NamedCollection <IArgumentDeclaration> declarations, ILocalIdentifierScope identifiers, ArgumentSide side, Type type, FieldToInstance fields) { if (type == null) { return; } foreach (var field in type.GetRuntimeFields()) { var argumentDecl = new ArgumentDeclaration { IsUnrolled = field.GetCustomAttributes(typeof(ArgumentUnrolled)).Any(), IsAssignable = field.GetCustomAttributes(typeof(ArgumentAssignable)).Any(), Name = field.Name, Type = NetTypeToRebuildType(field.FieldType) //Value = field.V }; var argument = new ArgumentInstance { Argument = argumentDecl, Side = side }; declarations.Add(argumentDecl); identifiers.Add(argument); arguments.Add(argument); fields.Add(field, argument); } }
public override void Visit(ArgumentDeclaration decl) { StartElement("parameterDeclaration"); Attribute("name", decl.Name); Attribute("type", decl.ValueType.Name); EndElement(); }
public override void Visit(ArgumentDeclaration decl) { cb.WriteLine(); cb.WriteIndent(); cb.Write(decl.ValueType.Name); cb.Write(' '); cb.Write(decl.Name); }
static NamedCollection <IArgumentDeclaration> ParseArgumentsDecl( IEnumerator <TokenData> tokens, IContext context, ArgumentSide side, ref bool done) { var result = new NamedCollection <IArgumentDeclaration>(); var token = tokens.Current; var withBracket = token.Type == Token.BracketOpen; if (withBracket) { if (!tokens.MoveNext()) { done = true; } if (done) { return(result); // TODO: report error dangling open bracket } token = tokens.Current; } var withComma = false; while (true) { var isAssignable = false; if (token.Type == Token.OperatorLiteral && ((IIdentifierLiteral)token.Data).Content == "*") { isAssignable = true; if (!tokens.MoveNext()) { done = true; } if (done) { return(result); // TODO: report missing value & dangling open bracket } token = tokens.Current; } if (token.Type != Token.IdentifierLiteral) { break; } var argName = ((IIdentifierLiteral)token.Data).Content; // TODO: check for duplicate argument names var argument = new ArgumentDeclaration { Name = argName, IsAssignable = isAssignable }; result.Add(argument); context.Identifiers.Add(new ArgumentInstance { Argument = argument, Side = side }); if (!tokens.MoveNext()) { done = true; } if (done) { return(result); // TODO: report error dangling open bracket } token = tokens.Current; #region Argument Type if (token.Type == Token.OperatorLiteral && ((IIdentifierLiteral)token.Data).Content == ":") { if (!tokens.MoveNext()) { done = true; } if (done) { return(result); // TODO: report missing type & dangling open bracket } token = tokens.Current; // TODO: expand ParseTypeExpression if (token.Type == Token.IdentifierLiteral) { var typeName = ((IIdentifierLiteral)token.Data).Content; if (context.Identifiers[typeName] is IModuleInstance typeEntry && typeEntry.IsType()) { argument.Type = typeEntry; } else { // TODO: report missing type } if (!tokens.MoveNext()) { done = true; } if (done) { return(result); // TODO: report dangling open bracket } token = tokens.Current; } } #endregion #region Default Value if (token.Type == Token.OperatorLiteral && ((IIdentifierLiteral)token.Data).Content == "=") { if (!tokens.MoveNext()) { done = true; } if (done) { return(result); // TODO: report missing value & dangling open bracket } argument.Value = ExpressionParser.Parse(tokens, context, ref done); if (done) { return(result); // TODO: report missing dangling open bracket } token = tokens.Current; } #endregion #region Comma Separator if (token.Type == Token.CommaSeparator) { if (!withComma && result.Count > 1) { // TODO: report inconsistent use of commas // handling: ignore } withComma = true; if (!tokens.MoveNext()) { done = true; } if (done) { return(result); } } else if (withComma) { // TODO: report inconsistent use of commas // handling: ignore } #endregion }
/// <summary> /// Visita un objecte 'ArgumentDeclaration' /// </summary> /// <param name="decl">L'objecte a visitar.</param> /// public override void Visit(ArgumentDeclaration decl) { cb.Write("{0} {1}", decl.ValueType.Name, decl.Name); }