private static object ParseArgument(string arg, out ArgumentTypes type) { // string literal if (arg.StartsWith("'") && arg.EndsWith("'")) { type = ArgumentTypes.STRING; return(arg.Substring(1, arg.Length - 2)); } // integer literal if (arg.All(Char.IsDigit)) { type = ArgumentTypes.INTEGER; return(int.Parse(arg)); } // decimal literal if (arg.All(c => Char.IsDigit(c) || c == '.')) { type = ArgumentTypes.FLOAT; return(double.Parse(arg)); } // null if (arg == "null") { type = ArgumentTypes.NULL; return(null); } type = ArgumentTypes.PROPERTY; return(arg); }
public bool MatchSig(JsMethodSignature signature, MatchAntiCycle antiCycle = null) { if (signature == this) { return(true); } antiCycle = antiCycle ?? new MatchAntiCycle(); if (this.MoreArgsType == null && (signature.MoreArgsType != null || signature.ArgumentTypes.Length > this.ArgumentTypes.Length)) { return(false); } if (!ArgumentTypes.Zip(signature.ArgumentTypes, (a, b) => a.MatchType(b, antiCycle)).All(_ => _)) { return(false); } if (!signature.ArgumentTypes.Skip(this.ArgumentTypes.Length).All(a => this.MoreArgsType.MatchType(a, antiCycle))) { return(false); } if (!this.ArgumentTypes.Skip(signature.ArgumentTypes.Length).All(a => a.MatchType(signature.MoreArgsType, antiCycle))) { return(false); } return(true); }
public TypeNode FreshCopy(Dictionary <TypeNode, TypeNode> Mappings, List <TypeNode> NonGeneric) { if (Name == null) { if (OccursIn(NonGeneric)) { return(this); } else { if (!Mappings.ContainsKey(this)) { Mappings[this] = new TypeNode(); } return(Mappings[this]); } } else { return(new TypeNode() { Name = Name, ResultType = ResultType == null ? null : ResultType.FreshCopy(Mappings, NonGeneric), ArgumentTypes = ArgumentTypes == null ? new List <TypeNode>() : ArgumentTypes.Select(a => a.FreshCopy(Mappings, NonGeneric)).ToList() }); } }
public Argument(string name, ArgumentTypes type) { Debug.Assert(!string.IsNullOrEmpty(name), "Terminal argument name can't be null or empty."); Name = name; Type = type; }
public override string ToString() { return(string.Format("{0}{1}({2}) -> {3}", IsStatic ? "static " : "", Name, string.Join(", ", ArgumentTypes.Select(a => JniEnvironment.Types.GetJniTypeNameFromClass(a))), JniReturnType)); }
/// <summary> /// Return true if two procedure nodes have same signature. /// </summary> /// <param name="other"></param> /// <returns></returns> public bool Matches(string name, List <ProtoCore.Type> argumentTypes) { if (argumentTypes == null) { throw new ArgumentNullException("argumentTypes"); } return(Name == name && ArgumentTypes.SequenceEqual(argumentTypes)); }
public override object VisitObjectAssnWithArguments(CryslGrammarParser.ObjectAssnWithArgumentsContext context) { Dictionary <int, string> argumentValues = new Dictionary <int, string>(); CryptoSignature cryptoSignature = new CryptoSignature(); //ArgumentTypes argumentTypes = new ArgumentTypes(); List <ArgumentTypes> argumentsList = new List <ArgumentTypes>(); foreach (var varName in context.VARNAME()) { //Check for crypto signature identifiers if (varName.Symbol.TokenIndex < context.COLON().Symbol.TokenIndex) { cryptoSignature.Event_Var_Name = varName.GetText(); } //Check for Object Assignment else if (varName.Symbol.TokenIndex > context.COLON().Symbol.TokenIndex&& varName.Symbol.TokenIndex < context.EQUALS().Symbol.TokenIndex) { cryptoSignature.Object_variable = varName.GetText(); } //Check for crypto signature methods else if (varName.Symbol.TokenIndex > context.EQUALS().Symbol.TokenIndex&& (varName.Symbol.TokenIndex < context.OP().Symbol.TokenIndex&& varName.Symbol.TokenIndex < context.CP().Symbol.TokenIndex)) { cryptoSignature.Method_Name = varName.GetText(); cryptoSignature.Is_property = false; } //Check for crypto signature argument values else if (varName.Symbol.TokenIndex > context.OP().Symbol.TokenIndex&& varName.Symbol.TokenIndex < context.CP().Symbol.TokenIndex) { argumentValues.Add(varName.Symbol.TokenIndex, varName.GetText()); } } //Check for optional arguments foreach (var opArguments in context.UNSCORE()) { if (opArguments.Symbol.TokenIndex > context.OP().Symbol.TokenIndex&& opArguments.Symbol.TokenIndex < context.CP().Symbol.TokenIndex) { argumentValues.Add(opArguments.Symbol.TokenIndex, opArguments.GetText()); } } var sortedArgumentsList = from arguments in argumentValues orderby arguments.Key ascending select arguments; foreach (KeyValuePair <int, string> sortedArguments in sortedArgumentsList) { ArgumentTypes argumentTypes = new ArgumentTypes(); argumentTypes.Argument = sortedArguments.Value; argumentsList.Add(argumentTypes); } cryptoSignature.Argument_types = argumentsList; return(cryptoSignature); }
public ArgumentsParser(string[] args) { if (args == null || args.Length == 0) { return; } ArgumentTypes currentArgType = ArgumentTypes.Unspecified; for (int i = 0; i < args.Length; i++) { string arg = args[i]; if (string.Compare(arg, ARG_NAME_FOLDER, true) == 0) { //наступний аргумент - значення currentArgType = ArgumentTypes.Folder; continue; } else { if (string.Compare(arg, ARG_NAME_AZURE_BLOB_ANIMATED_CONNECTION_STRING, true) == 0) { currentArgType = ArgumentTypes.AnimatedBlobsConnectionString; continue; } else { if (string.Compare(arg, ARG_NAME_UPDATE_DATABASE, true) == 0) { currentArgType = ArgumentTypes.UpdateDatabase; continue; } else { if (string.Compare(arg, ARG_NAME_AZURE_DB_SITEPAGES_CONNECTION_STRING, true) == 0) { currentArgType = ArgumentTypes.SitePagesConnectionString; continue; } } } } if (currentArgType == ArgumentTypes.Unspecified) { continue; //не зрозуміло що це, порушено порядок аргументів } _Arguments[currentArgType] = arg; currentArgType = ArgumentTypes.Unspecified; } //for }
/// <summary> /// Check If Valid Argument /// </summary> /// <param name="argument"></param> /// <param name="methodSymbol"></param> /// <returns></returns> private static bool IsArgumentValid(ArgumentTypes argument, IParameterSymbol methodSymbol, ICollection <ObjectsDeclaration> objectsDeclarations) { string objectType = GetTypeString(argument.Argument, objectsDeclarations); string methodSymbolType = $"{methodSymbol.Type.ContainingNamespace}.{methodSymbol.Type.Name.ToString()}"; if (!string.IsNullOrEmpty(objectType)) { if (methodSymbolType.Equals(objectType)) { return(true); } } return(false); }
public Type GetArgumentType(string argName) { var argProp = ArgumentTypes.GetType().GetTypeInfo().GetProperties().Where(f => f.Name.ToLower() == argName.ToLower()).FirstOrDefault(); if (argProp == null) { var argField = ArgumentTypes.GetType().GetTypeInfo().GetFields().Where(f => f.IsPublic && f.Name.ToLower() == argName.ToLower()).FirstOrDefault(); if (argField == null) { throw new EntityGraphQLCompilerException($"{argName} is not an argument on field {Name}"); } return(argField.FieldType); } return(argProp.PropertyType); }
public override void FromXML(XmlNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); type = (Types)System.Enum.Parse(typeof(Types), node["type"].FirstChild.Value); eventName = node["eventName"].FirstChild.Value; if (node["target"] != null && node["target"].HasChildNodes) target = GameObject.Find(node["target"].FirstChild.Value); if (node["methodName"] != null && node["methodName"].HasChildNodes) methodName = node["methodName"].FirstChild.Value; if (node["methodArgument"] != null && node["methodArgument"].HasChildNodes) methodArgument = node["methodArgument"].FirstChild.Value; argumentType = (ArgumentTypes)System.Enum.Parse(typeof(ArgumentTypes), node["argumentType"].FirstChild.Value); }
//public override void FromXML(XmlNode node, CameraPath cameraPath) //{ // base.FromXML(node, cameraPath); // type = (Types)System.Enum.Parse(typeof(Types), node["type"].FirstChild.Value); // eventName = node["eventName"].FirstChild.Value; // if (node["target"] != null && node["target"].HasChildNodes) // target = GameObject.Find(node["target"].FirstChild.Value); // if (node["methodName"] != null && node["methodName"].HasChildNodes) // methodName = node["methodName"].FirstChild.Value; // if (node["methodArgument"] != null && node["methodArgument"].HasChildNodes) // methodArgument = node["methodArgument"].FirstChild.Value; // argumentType = (ArgumentTypes)System.Enum.Parse(typeof(ArgumentTypes), node["argumentType"].FirstChild.Value); //} public override void FromXML(XMLNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); type = (Types)System.Enum.Parse(typeof(Types), node.GetValue("type>0>_text")); eventName = node.GetValue("eventName>0>_text"); if (node.GetValue("target>0>_text") != null) { target = GameObject.Find(node.GetValue("target>0>_text")); } if (node.GetValue("methodName>0>_text") != null) { methodName = node.GetValue("methodName>0>_text"); } if (node.GetValue("methodArgument>0>_text") != null) { methodArgument = node.GetValue("methodArgument>0>_text"); } argumentType = (ArgumentTypes)System.Enum.Parse(typeof(ArgumentTypes), node.GetValue("argumentType>0>_text")); }
public static void ShowWindow() { EditorWindow window = EditorWindow.GetWindow(typeof(FactsDefinitionWindow)); window.position = new Rect(200, 200, 1000, 700); definitions = FactDefinitionsContainer.Load(definitionsPath); /*List<FactDefinition> defaultDefinitions = new List<FactDefinition> (new FactDefinition[] { * new FactDefinition ("Equal", "Relation", "Self", "arg1.Equals(arg2)"), * new FactDefinition ("NotEqual", "Relation", "Self", "!arg1.Equals(arg2)")}); * * * foreach (FactDefinition fd in defaultDefinitions) * if (!definitions.Contains (fd)) * definitions.Add (fd);*/ argsTypes = ArgumentTypes.Load(argumentsPath); List <string> defaultArgsTypes = new List <string> (new string[] { "Self", "Position", "Rotation", "Scale", "Mass" }); foreach (string argType in defaultArgsTypes) { if (!argsTypes.Contains(argType)) { argsTypes.Add(argType); } } }
public override void FromXML(XmlNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); type = (Types)System.Enum.Parse(typeof(Types), node["type"].FirstChild.Value); eventName = node["eventName"].FirstChild.Value; if (node["target"] != null && node["target"].HasChildNodes) { target = GameObject.Find(node["target"].FirstChild.Value); } if (node["methodName"] != null && node["methodName"].HasChildNodes) { methodName = node["methodName"].FirstChild.Value; } if (node["methodArgument"] != null && node["methodArgument"].HasChildNodes) { methodArgument = node["methodArgument"].FirstChild.Value; } argumentType = (ArgumentTypes)System.Enum.Parse(typeof(ArgumentTypes), node["argumentType"].FirstChild.Value); }
public FObject Invoke(FunctionInvoker fi, FObject[] args) { var gotTypes = args.Select(x => x.Type).ToArray(); bool j = CallObjectTypes.Contains(gotTypes[0]); for (int i = 1; j && i < ArgumentTypes.Count; i++) { var item = ArgumentTypes[i]; if (item != FObjectType.Any && item != gotTypes[i]) { j = false; break; } } if (!j) { throw new RuntimeException($"Call did not match function signature of function '{Name}'. " + $"Expected {ArgumentTypes.PrettyArray()}, got {gotTypes.PrettyArray()}."); } return(Invokable.Invoke(fi, args)); }
/// <summary> /// Indicates that this argument is the default argument. /// </summary> /// <param name="type"> Specifies the error checking to be done on the argument. </param> public DefaultArgumentAttribute(ArgumentTypes type): base(type) {}
public override Int32 GetHashCode() { return(ArgumentTypes.Aggregate(base.GetHashCode() ^ ReturnType.GetHashCode(), (current, type) => current ^ type.GetHashCode())); }
public bool Matches(string functionName, int argCount) { return(functionName == Name && ArgumentTypes.Count() == argCount); }
//public bool Matches(string functionName, IEnumerable<Type> argumentTypes) //{ // return functionName == Name && argumentTypes.Count() == ArgumentTypes.Count() && // argumentTypes.Zip(ArgumentTypes, (call, sig) => Typecasts.CanCastTo(call,sig)).All(r => r == true); //} public bool DynamicMatches(string functionName, IEnumerable <object> arguments) { return(functionName == Name && arguments.Count() == ArgumentTypes.Count() && arguments.Zip(ArgumentTypes, (call, sig) => Typecasts.CanCastTo(call, sig)).All(r => r == true)); }
/// <summary> /// Allows control of command line parsing. /// </summary> /// <param name="argumentType"> Specifies the error checking to be done on the argument. </param> public ArgumentAttribute(ArgumentTypes argumentType) { ArgumentType = argumentType; }
/// <summary> /// Indicates that this argument is the default argument. /// </summary> /// <param name="argumentType"> Specifies the error checking to be done on the argument. </param> public DefaultArgumentAttribute(ArgumentTypes argumentType) : base(argumentType) { }
/// <summary> /// Allows control of command line parsing. /// </summary> /// <param name="type"> Specifies the error checking to be done on the argument. </param> public ArgumentAttribute(ArgumentTypes type) { this.type = type; }
public override bool Equals(object obj) { return(obj is AttributeNodeTemplate && ArgumentTypes.SequenceEqual(((AttributeNodeTemplate)obj).ArgumentTypes)); }
public Argument(ArgumentAttribute attribute, FieldInfo field, ReportError reporter) { longName = Parser.LongName(attribute, field); explicitShortName = Parser.ExplicitShortName(attribute); shortName = Parser.ShortName(attribute, field); hasHelpText = Parser.HasHelpText(attribute); helpText = Parser.HelpText(attribute, field); defaultValue = Parser.DefaultValue(attribute, field); elementType = ElementType(field); flags = Flags(attribute, field); this.field = field; seenValue = false; this.reporter = reporter; isDefault = attribute != null && attribute is DefaultArgumentAttribute; if (IsCollection) { collectionValues = new ArrayList(); } Debug.Assert(longName != null && longName.Length > 0); Debug.Assert(!isDefault || !ExplicitShortName); Debug.Assert(!IsCollection || AllowMultiple, "Collection arguments must have allow multiple"); Debug.Assert(!Unique || IsCollection, "Unique only applicable to collection arguments"); Debug.Assert(IsValidElementType(Type) || IsCollectionType(Type)); Debug.Assert((IsCollection && IsValidElementType(elementType)) || (!IsCollection && elementType == null)); Debug.Assert(!(IsRequired && HasDefaultValue), "Required arguments cannot have default value"); Debug.Assert(!HasDefaultValue || (defaultValue.GetType() == field.FieldType), "Type of default value must match field type"); }