Ejemplo n.º 1
0
        public static void GetServiceMethods(Request request, ReplyNode result, ErrorNode error)
        {
            int serviceId;

            if (Int32.TryParse(request.ParameterSet["serviceId"], out serviceId))
            {
                using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                    ISingleResult <xspGetServiceMethodsResult> results = db.xspGetServiceMethods(serviceId);
                    XmlElement methods = result.AddElement("methods");

                    XmlElement method;
                    foreach (xspGetServiceMethodsResult r in results)
                    {
                        method = result.AddElement(methods, "method");
                        result.AddElement(method, "id", r.MethodId.ToString());
                        result.AddElement(method, "serviceid", r.ServiceId.ToString());
                        result.AddElement(method, "key", r.MethodKey);
                        result.AddElement(method, "name", r.MethodName);
                        result.AddElement(method, "cachedresultlifetime", r.CachedResultLifetime.ToString());
                        result.AddElement(method, "cacheresult", (r.IsResultCacheable ? "true" : "false"));
                        result.AddElement(method, "restricted", (r.IsRestricted ? "true" : "false"));
                        result.AddElement(method, "public", (r.IsPublic ? "true" : "false"));
                        result.AddElement(method, "logged", (r.IsLogged ? "true" : "false"));
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void GetService(Request request, ReplyNode result, ErrorNode error)
        {
            if (request.ParameterSet.ContainsKey("serviceid"))
            {
                int    serviceid  = request.ParameterSet.GetInt("serviceid");
                string resultcode = null;

                using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                    ISingleResult <xspGetServiceResult> results = db.xspGetService(serviceid, ref resultcode);

                    foreach (xspGetServiceResult service in results)
                    {
                        result.AddElement("assemblyname", service.AssemblyName);
                        result.AddElement("classname", service.ClassName);
                        result.AddElement("consumeriprange", service.ConsumerIPRange);
                        result.AddElement("description", service.Description);
                        result.AddElement("servicekey", service.ServiceKey);
                        result.AddElement("logged", (service.IsLogged ? "true" : "false"));
                        result.AddElement("public", (service.IsPublic ? "true" : "false"));
                        result.AddElement("restricted", (service.IsRestricted ? "true" : "false"));
                    }

                    result.AddElement("resultcode", resultcode);
                }
            }
            else
            {
                error.Text = "No service specified.";
            }
        }
    public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
    {
        var jToken = JToken.ReadFrom(reader);

        var refString      = jToken.Value <string>("$ref");
        var firstReference = refString == null;

        if (firstReference)
        {
            var typeString = jToken.Value <string>("$type");

            if (typeString != null)
            {
                var type = Type.GetType(typeString);

                if (type == null)
                {
                    var errorNode = new ErrorNode();

                    errorNode.JToken           = jToken;
                    errorNode.FailedTypeString = typeString;

                    // Apply the old node's relationships to errorNode
                    serializer.Populate(jToken.CreateReader(), errorNode);

                    return(errorNode);
                }
            }
        }

        // Default-like behaviour
        return(serializer.Deserialize(jToken.CreateReader()));
    }
Ejemplo n.º 4
0
        public static void ExpireResultCache(Request request, ReplyNode result, ErrorNode error)
        {
            if (request.ParameterSet.Verify(VerificationGroups.ExpireResultCache))
            {
                if (request.Application.HasPermissionTo(request.ParameterSet.GetString("Service"), request.ParameterSet.GetString("Method")))
                {
                    int?itemcount = null;
                    using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                        db.xspExpireResultsCache(
                            request.ParameterSet.GetString("Service"),
                            request.ParameterSet.GetString("Method"),
                            ref itemcount
                            );

                        result.AddElement("count", (itemcount == null ? "0" : itemcount.ToString()));
                    }
                }
                else
                {
                    throw new Exception(request.Service.Settings["ApplicationPermissionErrorMessage"].Build(new Dictionary <string, string>()
                    {
                        { "applicationname", request.Application.Name },
                        { "service", request.ParameterSet.GetString("Service") },
                        { "method", request.ParameterSet.GetString("Method") }
                    }));
                }
            }
            else
            {
                error.Text = VerificationGroups.ExpireResultCache.GetDefinition();
            }
        }
Ejemplo n.º 5
0
        public static void RevokeApplicationKey(Request request, ReplyNode result, ErrorNode error)
        {
            int?   applicationid = null;
            string key           = null;
            string resultcode    = null;

            if (request.ParameterSet.Verify(new ParameterVerificationGroup("id", ParameterType.Int)))
            {
                applicationid = request.ParameterSet.GetInt("id");
            }
            else if (request.ParameterSet.ContainsKey("key"))
            {
                key = request.ParameterSet["key"];
            }

            using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                db.xspRevokeKey(applicationid, key, resultcode);

                if (resultcode == "SUCCESS")
                {
                    result.AddElement("result", resultcode);
                }
                else
                {
                    error.Text = resultcode;
                }
            }
        }
Ejemplo n.º 6
0
        public static void UpdateService(Request request, ReplyNode result, ErrorNode error)
        {
            string sId             = request.ParameterSet["id"],
                   key             = request.ParameterSet["servicekey"],
                   description     = request.ParameterSet["description"],
                   consumeriprange = request.ParameterSet["consumeriprange"],
                   assembly        = request.ParameterSet["assembly"],
                   serviceclass    = request.ParameterSet["class"],
                   resultcode      = null;
            bool?isrestricted      = (request.ParameterSet["restricted"] == "true" ? true : false);
            bool?ispublic          = (request.ParameterSet["public"] == "true" ? true : false);
            bool?islogged          = (request.ParameterSet["logged"] == "true" ? true : false);
            int  id;
            int? nId;

            if (Int32.TryParse(sId, out id))
            {
                nId = id;
                using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                    db.xspUpdateService(ref nId, key, description, consumeriprange, assembly, serviceclass, isrestricted, ispublic, islogged, ref resultcode);
                }

                XmlElement r = result.AddElement("result");
                result.AddElement(r, "resultcode", resultcode);

                if (sId == "-1")
                {
                    result.AddElement(r, "id", nId.ToString());
                }
            }
            else
            {
                error.Text = "not a valid id";
            }
        }
Ejemplo n.º 7
0
        public static void GetAssemblyDirectory(Request request, ReplyNode result, ErrorNode error)
        {
            string assemblyDirectory = null;

            using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                db.xspGetSettingByKey("AssemblyDirectory", ref assemblyDirectory);
                result.AddElement("assemblydirectory", assemblyDirectory);
            }
        }
Ejemplo n.º 8
0
        public static void DeleteServiceSetting(Request request, ReplyNode result, ErrorNode error)
        {
            int?   id         = Int32.Parse(request.ParameterSet["id"]);
            int?   serviceid  = Int32.Parse(request.ParameterSet["serviceid"]);
            string resultcode = null;

            using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                db.xspDeleteServiceSetting(id, serviceid, ref resultcode);
                result.AddElement("resultcode", resultcode);
            }
        }
Ejemplo n.º 9
0
 void WriteOutAnyErrors()
 {
     for (int i = 0, n = this.errors == null ? 0 : this.errors.Count; i < n; i++)
     {
         ErrorNode e = this.errors[i];
         if (e != null)
         {
             Console.WriteLine(e.GetMessage());
         }
     }
     this.errors = new ErrorNodeList();
 }
Ejemplo n.º 10
0
 public static void GetRateLimitTypes(Request request, ReplyNode result, ErrorNode error)
 {
     using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
         XmlElement xRateType, xRateTypes = result.AddElement("ratelimittypes");
         ISingleResult <xspGetRateLimitTypesResult> rates = db.xspGetRateLimitTypes();
         foreach (xspGetRateLimitTypesResult rate in rates)
         {
             xRateType = result.AddElement(xRateTypes, "ratelimittype");
             xRateType.SetAttribute("id", rate.Id.ToString());
             xRateType.InnerText = rate.Name;
         }
     }
 }
Ejemplo n.º 11
0
        public override Node Mutate(ErrorNode node)
        {
            if (_random.NextDouble() <= CrossoverProbability)
            {
                return(Crossover());
            }

            if (_random.NextDouble() <= FullMutationProbability)
            {
                return(FullMutation());
            }

            return(base.Mutate(node));
        }
Ejemplo n.º 12
0
        public static void UpdateServiceSetting(Request request, ReplyNode result, ErrorNode error)
        {
            int?   id        = Int32.Parse(request.ParameterSet["id"]);
            int?   serviceid = (request.ParameterSet["serviceid"] == null ? null : (int?)Int32.Parse(request.ParameterSet["serviceid"]));
            string name      = request.ParameterSet["name"];
            string value     = request.ParameterSet["value"];
            bool?  encrypted = (request.ParameterSet["encrypted"] == "true" ? true : false);

            string resultcode = null;

            using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                if (id == -1)
                {
                    if (encrypted == true)
                    {
                        Encryption.Packet packet = Encryption.Module.EncryptString(new Encryption.Packet()
                        {
                            ClearText = value
                        });

                        db.xspUpdateServiceSetting(ref id, serviceid, name, packet.IV, packet.CipherText, encrypted, ref resultcode);
                    }
                    else
                    {
                        db.xspUpdateServiceSetting(ref id, serviceid, name, null, value, encrypted, ref resultcode);
                    }

                    result.AddElement("id", id.ToString());
                }
                else
                {
                    if (encrypted == true)
                    {
                        Encryption.Packet packet = Encryption.Module.EncryptString(new Encryption.Packet()
                        {
                            ClearText = value
                        });

                        db.xspUpdateServiceSetting(ref id, serviceid, name, packet.IV, packet.CipherText, encrypted, ref resultcode);
                    }
                    else
                    {
                        db.xspUpdateServiceSetting(ref id, serviceid, name, null, value, encrypted, ref resultcode);
                    }
                }

                result.AddElement("resultcode", resultcode);
            }
        }
Ejemplo n.º 13
0
        public static void GetNewApplicationKey(Request request, ReplyNode result, ErrorNode error)
        {
            string appKey    = null;
            bool?  collision = true;

            using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                while (collision != false)
                {
                    appKey = Guid.NewGuid().ToString().ToUpper();
                    db.xspCheckApplicationKeyForCollision(appKey, ref collision);
                }
            }

            result.AddElement("applicationkey", appKey);
        }
Ejemplo n.º 14
0
        public static void GetApplicationList(Request request, ReplyNode result, ErrorNode error)
        {
            XmlElement applications = result.AddElement("applications");

            using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                ISingleResult <xspGetApplicationListResult> results = db.xspGetApplicationList();

                XmlElement application;
                foreach (xspGetApplicationListResult r in results)
                {
                    application = result.AddElement(applications, "application");
                    result.AddElement(application, "id", r.ApplicationId.ToString());
                    result.AddElement(application, "name", r.ApplicationName);
                }
            }
        }
Ejemplo n.º 15
0
        public static void GetServerStatus(Request request, ReplyNode result, ErrorNode error)
        {
            using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                ISingleResult <xspGetServerStatusResult> results = db.xspGetServerStatus();

                XmlElement host, hosts = result.AddElement("servers");
                foreach (xspGetServerStatusResult r in results)
                {
                    host = result.AddElement(hosts, "server");
                    host.SetAttribute("id", r.Id.ToString());

                    result.AddElement(host, "ipaddress", r.IPAddress);
                    result.AddElement(host, "hostname", r.HostName);
                    result.AddElement(host, "cacherefreshrequired", (r.IsCacheRefreshRequired ? "true" : "false"));
                    result.AddElement(host, "assemblyrefreshrequired", (r.IsAssemblyRefreshRequired ? "true" : "false"));
                }
            }
        }
Ejemplo n.º 16
0
        private DataNode GetExpressionNode(string item)
        {
            DataNode node;

            try
            {
                if (!PluginMain.debugManager.FlashInterface.isDebuggerStarted || !PluginMain.debugManager.FlashInterface.isDebuggerSuspended)
                {
                    return(new ErrorNode(item, new Exception("")));
                }

                IASTBuilder builder = new ASTBuilder(false);
                ValueExp    exp     = builder.parse(new java.io.StringReader(item));
                var         ctx     = new ExpressionContext(PluginMain.debugManager.FlashInterface.Session, PluginMain.debugManager.FlashInterface.GetFrames()[PluginMain.debugManager.CurrentFrame]);
                var         obj     = exp.evaluate(ctx);
                if (obj is Variable)
                {
                    node = new VariableNode((Variable)obj)
                    {
                        HideClassId       = PluginMain.settingObject.HideClassIds,
                        HideFullClasspath = PluginMain.settingObject.HideFullClasspaths
                    };
                }
                else if (obj is Value)
                {
                    node = new ValueNode(item, (Value)obj)
                    {
                        HideClassId       = PluginMain.settingObject.HideClassIds,
                        HideFullClasspath = PluginMain.settingObject.HideFullClasspaths
                    };
                }
                else
                {
                    node = new ScalarNode(item, obj.toString());
                }
                node.Tag = item;
            }
            catch (Exception ex)
            {
                node = new ErrorNode(item, ex);
            }
            node.Text = item;
            return(node);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// return the level of the most severe error.
        /// </summary>
        /// <param name="errors"></param>
        /// <returns></returns>
        static public int ErrorSeverity(ErrorNodeList errors)
        {
            int severity = int.MaxValue;

            for (int i = 0; i < errors.Count; i++)
            {
                ErrorNode e = errors[i];
                if (e == null)
                {
                    continue;
                }
                if (e.Severity < 0)
                {
                    continue;
                }
                severity = severity > e.Severity ? e.Severity : severity;
            }
            return(severity);
        }
Ejemplo n.º 18
0
        public static void GetMethodList(Request request, ReplyNode result, ErrorNode error)
        {
            XmlElement methods = result.AddElement("methods");

            using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                ISingleResult <xspGetMethodsResult> results = db.xspGetMethods();

                XmlElement method;
                foreach (xspGetMethodsResult r in results)
                {
                    method = result.AddElement(methods, "method");
                    result.AddElement(method, "id", r.MethodId.ToString());
                    result.AddElement(method, "key", r.MethodKey);
                    result.AddElement(method, "name", r.MethodName);
                    result.AddElement(method, "public", (r.IsPublic ? "true" : "false"));
                    result.AddElement(method, "restricted", (r.IsRestricted == true ? "true" : "false"));
                }
            }
        }
Ejemplo n.º 19
0
        public static void UpdateServiceMethod(Request request, ReplyNode result, ErrorNode error)
        {
            string sId          = request.ParameterSet["id"],
                   sServiceId   = request.ParameterSet["serviceid"],
                   methodKey    = request.ParameterSet["methodkey"],
                   methodName   = request.ParameterSet["methodname"],
                   resultcode   = null;
            bool?isresultcached = (request.ParameterSet["cacheresult"] == "true" ? true : false);
            bool?isrestricted   = (request.ParameterSet["restricted"] == "true" ? true : false);
            bool?ispublic       = (request.ParameterSet["public"] == "true" ? true : false);
            bool?islogged       = (request.ParameterSet["logged"] == "true" ? true : false);
            //bool? islogreplaydetailsonexception = (request.ParameterSet["logreplaydetailsonexception"] == "true" ? true : false);
            int id, serviceId, cachedResultLifetime;
            int?nId, nServiceId, nCachedResultLifetime = null;

            if (Int32.TryParse(sId, out id) && Int32.TryParse(sServiceId, out serviceId) && Int32.TryParse(sServiceId, out serviceId))
            {
                nId = id; nServiceId = serviceId;

                if (Int32.TryParse(request.ParameterSet["cachedresultlifetime"], out cachedResultLifetime))
                {
                    nCachedResultLifetime = cachedResultLifetime;
                }

                using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                    db.xspUpdateServiceMethod(ref nId, nServiceId, methodKey, methodName, cachedResultLifetime, isresultcached, isrestricted, ispublic, islogged, ref resultcode);
                }

                XmlElement r = result.AddElement("result");
                result.AddElement(r, "resultcode", resultcode);

                if (sId == "-1")
                {
                    result.AddElement(r, "id", nId.ToString());
                }
            }
            else
            {
                error.Text = "not a valid id";
            }
        }
Ejemplo n.º 20
0
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            ErrorNode errorNode = obj as ErrorNode;

            if (errorNode == null || !(this.errorCode == errorNode.errorCode) || (!this.SourceContext.Equals((object)errorNode.SourceContext) || this.errorParameters.Length != errorNode.errorParameters.Length))
            {
                return(false);
            }
            for (int index = 0; index < this.errorParameters.Length; ++index)
            {
                if (this.errorParameters[index] != errorNode.errorParameters[index])
                {
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 21
0
        public static void GetServiceSettings(Request request, ReplyNode result, ErrorNode error)
        {
            int        serviceid;
            string     resultcode = null;
            XmlElement element, parent;

            if (request.ParameterSet["id"] != null && Int32.TryParse(request.ParameterSet["id"], out serviceid))
            {
                using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                    ISingleResult <xspGetServiceSettingsResult> settings = db.xspGetServiceSettings(null, serviceid, ref resultcode);

                    parent = result.AddElement("settings");
                    foreach (xspGetServiceSettingsResult s in settings)
                    {
                        element = result.AddElement(parent, "setting");
                        result.AddElement(element, "id", s.Id.ToString());
                        result.AddElement(element, "name", s.Name);

                        if (s.IsEncrypted)
                        {
                            Encryption.Packet packet = Encryption.Module.DecryptString(new Encryption.Packet()
                            {
                                IV         = s.IV,
                                CipherText = s.Value,
                            });

                            result.AddElement(element, "value", packet.ClearText);
                            result.AddElement(element, "encrypted", "true");
                        }
                        else
                        {
                            result.AddElement(element, "value", s.Value);
                            result.AddElement(element, "encrypted", "false");
                        }
                    }

                    result.AddElement(parent, "resultcode", resultcode);
                }
            }
        }
Ejemplo n.º 22
0
        public static void DeleteServiceMethod(Request request, ReplyNode result, ErrorNode error)
        {
            string sId        = request.ParameterSet["id"],
                   resultcode = null;
            int id;
            int?nId;

            if (Int32.TryParse(sId, out id))
            {
                nId = id;
                using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                    db.xspDeleteServiceMethod(nId, ref resultcode);
                }

                XmlElement r = result.AddElement("result");
                result.AddElement(r, "resultcode", resultcode);
            }
            else
            {
                error.Text = "not a valid id";
            }
        }
Ejemplo n.º 23
0
        public static void UpdateApplication(Request request, ReplyNode result, ErrorNode error)
        {
            string sId         = request.ParameterSet["id"],
                   name        = request.ParameterSet["name"],
                   key         = request.ParameterSet["appkey"],
                   range       = (request.ParameterSet["range"].Length == 0 ? null : request.ParameterSet["range"]),
                   description = request.ParameterSet["description"],
                   resultcode  = null;
            bool?ispublic      = (request.ParameterSet["public"] == "true" ? true : false);
            bool?islogged      = (request.ParameterSet["logged"] == "true" ? true : false);

            int?ratelimitid       = (request.ParameterSet["ratelimittypeid"].Length > 0 ? (int?)int.Parse(request.ParameterSet["ratelimittypeid"]) : null);
            int?ratelimit         = (request.ParameterSet["ratelimittypeid"].Length > 0 ? (int?)int.Parse(request.ParameterSet["ratelimit"]) : null);
            int?ratelimitinterval = (request.ParameterSet["ratelimittypeid"].Length > 0 ? (int?)int.Parse(request.ParameterSet["ratelimitinterval"]) : null);

            int id;
            int?nId;

            if (Int32.TryParse(sId, out id))
            {
                nId = id;
                using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                    db.xspUpdateApplication(ref nId, name, key, range, description, ratelimitid, ratelimit, ratelimitinterval, ispublic, islogged, ref resultcode);
                }

                XmlElement r = result.AddElement("result");
                result.AddElement(r, "resultcode", resultcode);

                if (sId == "-1")
                {
                    result.AddElement(r, "id", nId.ToString());
                }
            }
            else
            {
                error.Text = "not a valid id";
            }
        }
Ejemplo n.º 24
0
        public ValidationNode Validate(
            ISerializationManager serialization,
            MappingDataNode mapping,
            ISerializationContext?context)
        {
            var validatedMapping = new Dictionary <ValidationNode, ValidationNode>();

            foreach (var(key, val) in mapping.Children)
            {
                if (key is not ValueDataNode valueDataNode)
                {
                    validatedMapping.Add(new ErrorNode(key, "Key not ValueDataNode."), new InconclusiveNode(val));
                    continue;
                }

                var field = BaseFieldDefinitions.FirstOrDefault(f => f.Attribute.Tag == valueDataNode.Value);
                if (field == null)
                {
                    var error = new ErrorNode(
                        key,
                        $"Field \"{valueDataNode.Value}\" not found in \"{Type}\".",
                        false);

                    validatedMapping.Add(error, new InconclusiveNode(val));
                    continue;
                }

                var            keyValidated = serialization.ValidateNode(typeof(string), key, context);
                ValidationNode valValidated = field.Attribute.CustomTypeSerializer != null
                    ? serialization.ValidateNodeWith(field.FieldType,
                                                     field.Attribute.CustomTypeSerializer, val, context)
                    : serialization.ValidateNode(field.FieldType, val, context);

                validatedMapping.Add(keyValidated, valValidated);
            }

            return(new ValidatedMappingNode(validatedMapping));
        }
Ejemplo n.º 25
0
        public static void GetServiceList(Request request, ReplyNode result, ErrorNode error)
        {
            XmlElement services = result.AddElement("services");

            using (LegionLinqDataContext db = new LegionLinqDataContext(request.Service.Settings["LegionConnectionString"])) {
                ISingleResult <xspGetServicesResult> results = db.xspGetServices();

                XmlElement service;
                foreach (xspGetServicesResult r in results)
                {
                    service = result.AddElement(services, "service");
                    result.AddElement(service, "id", r.ServiceId.ToString());
                    result.AddElement(service, "key", r.ServiceKey);
                    result.AddElement(service, "assembly", r.AssemblyName);
                    result.AddElement(service, "class", r.ClassName);
                    result.AddElement(service, "restricted", (r.IsRestricted ? "true" : "false"));
                    result.AddElement(service, "public", (r.IsPublic ? "true" : "false"));
                    result.AddElement(service, "logged", (r.IsLogged ? "true" : "false"));
                    result.AddElement(service, "description", r.Description);
                    result.AddElement(service, "consumeriprange", r.ConsumerIPRange);
                }
            }
        }
Ejemplo n.º 26
0
 public override dynamic Visit(ErrorNode node)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 27
0
 public override void Visit(ErrorNode node)
 {
 }
Ejemplo n.º 28
0
 public static XamlParseError XmlError(ErrorNode errorNode, IReadableSelectableTextBuffer textBuffer, int offset)
 {
     return(XamlParseErrors.NewParseError(XamlErrorSeverity.Error, XamlErrorCode.XmlError, textBuffer.GetLocation(errorNode.SourceContext.StartCol + offset), errorNode.ErrorCode, errorNode.ErrorParameters));
 }
Ejemplo n.º 29
0
 public void ReportError(ErrorNode error, string message)
 {
     Console.WriteLine("Error found at " + error.ToString());
 }
Ejemplo n.º 30
0
 public override Result Visit(ErrorNode node, Context context)
 {
     return(Default);
 }
Ejemplo n.º 31
0
 public virtual bool IsWarningRelatedMessage(ErrorNode enode){
   if (enode == null) return false;
   return enode.Code == (int)Error.RelatedWarningLocation || enode.Code == (int)Error.RelatedWarningModule;
 }
		public virtual Value evaluate(Context cx, ErrorNode node)
		{
			output("<ErrorNode position=\"" + node.pos() + "\"/>");
			return null;
		}
Ejemplo n.º 33
0
 /// <summary>
 /// Send a message to the development enviroment. The kind of message
 /// is specified through the given severity. 
 /// </summary>
 public abstract void AddError(ErrorNode node);
Ejemplo n.º 34
0
        public ITreeNode Program()
        {
            ITreeNode programNode = new ErrorNode();

            switch (curTokenType)
            {
                case TokenType.BEGINBL:
                    Match(ref matchToken, TokenType.BEGINBL);
                    ITreeNode someStatement = Program();
                    BlockNode block = new BlockNode();
                    block.addStatement(someStatement);
                    while (curTokenType != TokenType.ENDBL)
                    {
                        someStatement = Program();
                        block.addStatement(someStatement);
                    }
                    Match(ref matchToken, TokenType.ENDBL);
                    programNode = block;
                    break;
                case TokenType.LABEL:
                    Match(ref matchToken, TokenType.LABEL);
                    LabelNode labeledBlock = new LabelNode(matchToken.getValue());
                    ITreeNode labeledStatement;
                    do
                    {
                        labeledStatement = Program();
                        labeledBlock.addStatement(labeledStatement);
                    }
                    while (curTokenType != TokenType.EOF);
                    programNode = labeledBlock;
                    break;
                case TokenType.INTDEC:
                    Match(ref matchToken, TokenType.INTDEC);
                    Match(ref matchToken, TokenType.ID);
                    programNode = new IdentifierDeclarationNode(IdentifierType.INT, matchToken.getValue());
                    Match(ref matchToken, TokenType.EOS);
                    break;
                case TokenType.BOOLDEC:
                    Match(ref matchToken, TokenType.BOOLDEC);
                    Match(ref matchToken, TokenType.ID);
                    programNode = new IdentifierDeclarationNode(IdentifierType.BOOL, matchToken.getValue());
                    Match(ref matchToken, TokenType.EOS);
                    break;
                case TokenType.FOR:
                    Match(ref matchToken, TokenType.FOR);
                    Match(ref matchToken, TokenType.LPAREN);
                    AssignmentNode init = (AssignmentNode)Program();
                    AssignmentNode step = (AssignmentNode)Program();
                    BooleanExpressionNode condition = (BooleanExpressionNode)BooleanExpression();
                    Match(ref matchToken, TokenType.RPAREN);
                    BlockNode forBody = (BlockNode)Program();
                    programNode = new ForNode(init, step, condition, forBody);
                    break;
                /*case TokenType.FUN:
                    Match(ref matchToken, TokenType.FUN);
                    IdentifierNode id = (IdentifierNode)Factor();
                    programNode = new FunctionNode(id);
                    Match(ref matchToken, TokenType.EOS);
                    break;*/
                case TokenType.GOTO:
                    Match(ref matchToken, TokenType.GOTO);
                    Match(ref matchToken, TokenType.ID);
                    IdentifierNode gotoLabel = new IdentifierNode(matchToken.getValue(), IdentifierType.LABEL);
                    programNode = new GotoNode(gotoLabel);
                    Match(ref matchToken, TokenType.EOS);
                    break;
                case TokenType.ID:
                    Match(ref matchToken, TokenType.ID);
                    IdentifierNode assignId = new IdentifierNode(matchToken.getValue(), IdentifierType.UNKNOWN);
                    Match(ref matchToken, TokenType.ASSIGN);
                    BooleanExpressionNode assignValue = (BooleanExpressionNode)BooleanExpression();
                    programNode = new AssignmentNode(assignId, assignValue);
                    Match(ref matchToken, TokenType.EOS);
                    break;
                case TokenType.IF:
                    Match(ref matchToken, TokenType.IF);
                    ITreeNode thenBranch;
                    ITreeNode elseBranch;

                    Match(ref matchToken, TokenType.LPAREN);
                    BooleanExpressionNode ifCondition = (BooleanExpressionNode)BooleanExpression();
                    Match(ref matchToken, TokenType.RPAREN);
                    Match(ref matchToken, TokenType.THEN);
                    thenBranch = (BlockNode)Program();
                    if (curTokenType == TokenType.ELSE)
                    {
                        Match(ref matchToken, TokenType.ELSE);
                        elseBranch = (BlockNode)Program();
                    }
                    else
                    {
                        elseBranch = new BlankNode();
                    }
                    programNode = new IfNode(ifCondition, thenBranch, elseBranch);
                    break;
                /*case TokenType.LET:
                    Match(ref matchToken, TokenType.LET);
                    IdentifierNode shortId = (IdentifierNode)Factor();
                    Match(ref matchToken, TokenType.ASSIGN);
                    BooleanExpressionNode subst = (BooleanExpressionNode)BooleanExpression();
                    Match(ref matchToken, TokenType.IN);
                    BooleanExpressionNode target = (BooleanExpressionNode)BooleanExpression();
                    programNode = new LetNode(shortId, subst, target);
                    Match(ref matchToken, TokenType.EOS);
                    break;*/
                case TokenType.PRINT:
                    Match(ref matchToken, TokenType.PRINT);
                    Match(ref matchToken, TokenType.LPAREN);
                    BooleanExpressionNode printArgument = (BooleanExpressionNode)BooleanExpression();
                    Match(ref matchToken, TokenType.RPAREN);
                    programNode = new PrintNode(printArgument);
                    Match(ref matchToken, TokenType.EOS);
                    break;
                case TokenType.WHILE:
                    Match(ref matchToken, TokenType.WHILE);
                    Match(ref matchToken, TokenType.LPAREN);
                    BooleanExpressionNode whileCondition = (BooleanExpressionNode)BooleanExpression();
                    Match(ref matchToken, TokenType.RPAREN);
                    BlockNode whileBody = (BlockNode)Program();
                    programNode = new WhileNode(whileCondition, whileBody);
                    break;
                case TokenType.EOF:
                    programNode = new BlankNode();
                    break;
                default:
                    Expect(TokenType.UNKNOWN, lookAheadToken);
                    break;
            }
            return programNode;
        }
Ejemplo n.º 35
0
        public IArithmeticNode Term()
        {
            IArithmeticNode firstOpNode = Factor();
            IArithmeticNode secondOpNode;
            IArithmeticNode termNode = new TermNode(TokenType.UNKNOWN, firstOpNode, null);

            while ((curTokenType == TokenType.MULT) ||
                    (curTokenType == TokenType.DIV) ||
                    (curTokenType == TokenType.POWER))
            {
                switch (curTokenType)
                {
                    case TokenType.MULT:
                        Match(ref matchToken, TokenType.MULT);
                        secondOpNode = Term();
                        termNode = new TermNode(TokenType.MULT, firstOpNode, secondOpNode);
                        break;
                    case TokenType.DIV:
                        Match(ref matchToken, TokenType.DIV);
                        secondOpNode = Term();
                        termNode = new TermNode(TokenType.DIV, firstOpNode, secondOpNode);
                        break;
                    case TokenType.POWER:
                        Match(ref matchToken, TokenType.POWER);
                        secondOpNode = Term();
                        termNode = new TermNode(TokenType.POWER, firstOpNode, secondOpNode);
                        break;
                    default:
                        Expect(TokenType.UNKNOWN, lookAheadToken);
                        termNode = new ErrorNode();
                        break;
                }
            }
            return termNode;
        }