Beispiel #1
0
            public void Format(IPaperContext context, IObjectFactory factory, Entity entity)
            {
                // TODO: deveriamos consultar o catalogo
                // var paperCatalog = factory.GetInstance<IPaperCatalog>();
                // paperCatalog.FindByType(typeof(TPaper));
                var paper           = (IPaper)Activator.CreateInstance(paperType);
                var paperDescriptor = new PaperDescriptor(paper);

                var href = paperDescriptor.PathTemplate.Substring(1);

                if (paperArgs != null)
                {
                    foreach (var arg in paperArgs)
                    {
                        var value = Change.To <string>(arg);
                        href = Regex.Replace(href, @"\{[^{}]+\}", value);
                    }
                }

                if (Rel?.Any() != true)
                {
                    this.AddRel(RelNames.Link);
                }

                this.Href = href;
            }
        /// <summary>
        /// Gets API resources by scope name.
        /// </summary>
        /// <param name="scopeNames"></param>
        /// <returns></returns>
        public async Task <IEnumerable <ApiResource> > FindApiResourcesByScopeAsync(IEnumerable <string> scopeNames)
        {
            var names = scopeNames.ToArray();

            using (ISession session = _context.GetDriver().Session())
            {
                Node a      = new Node(type: typeof(ApiResource));
                Node secret = new Node(type: typeof(Secret));
                Node scope  = new Node(type: typeof(Scope));
                Rel  rel    = new Rel(type: typeof(Relationships.Has));

                List <ApiResource> result = await session.AsAsync(s =>
                                                                  s.ExecuteQuery <ApiResource, IEnumerable <Secret>, IEnumerable <Scope> >(
                                                                      $"MATCH (c{a.Labels}) " +
                                                                      $"OPTIONAL MATCH (c)-{rel}->(s{secret.Labels}) " +
                                                                      $"OPTIONAL MATCH (c)-{rel}->(sc{scope.Labels}) " +
                                                                      $"WITH c,s,sc ORDER BY id(c),id(s),id(sc) " +
                                                                      $"WITH c, {{s:collect(distinct s), sc:collect(distinct sc)}} AS val " +
                                                                      $"WITH c, val.s AS s, val.sc AS sc " +
                                                                      $"WHERE sc IS NOT NULL AND FILTER(x in sc where x.{nameof(Scope.Name)} in ${nameof(names)}) <> [] " +
                                                                      $"WITH c,s,sc ORDER BY id(c) " +
                                                                      $"RETURN c, s, sc",
                                                                      (api, secrets, scopes) =>
                {
                    api.ApiSecrets = secrets?.Select(p => p as Secret)?.ToList();
                    api.Scopes = scopes?.Select(p => p as Scope)?.ToList();
                    return(api);
                },
                                                                      new { names })
                                                                  .ToList());

                return(result);
            }
        }
        /// <summary>
        /// Finds the API resource by name.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public async Task <ApiResource> FindApiResourceAsync(string name)
        {
            using (ISession session = _context.GetDriver().Session())
            {
                Node a      = new Node(type: typeof(ApiResource));
                Node secret = new Node(type: typeof(Secret));
                Node scope  = new Node(type: typeof(Scope));
                Rel  rel    = new Rel(type: typeof(Relationships.Has));

                ApiResource result = await session.AsAsync(s =>
                                                           s.ExecuteQuery <ApiResource, IEnumerable <Secret>, IEnumerable <Scope> >(
                                                               $"MATCH (c{a.Labels} {{{nameof(ApiResource.Name)}:${nameof(name)}}}) " +
                                                               $"OPTIONAL MATCH (c)-{rel}->(s{secret.Labels}) " +
                                                               $"OPTIONAL MATCH (c)-{rel}->(sc{scope.Labels}) " +
                                                               $"WITH c,s,sc ORDER BY id(c),id(s),id(sc) " +
                                                               $"WITH c, {{s:collect(distinct s), sc:collect(distinct sc)}} AS val " +
                                                               $"WITH c, val.s AS s, val.sc AS sc " +
                                                               $"RETURN c, s, sc",
                                                               (api, secrets, scopes) =>
                {
                    api.ApiSecrets = secrets?.Select(p => p as Secret)?.ToList();
                    api.Scopes = scopes?.Select(p => p as Scope)?.ToList();
                    return(api);
                },
                                                               new { name })
                                                           .FirstOrDefault());

                _logger.LogDebug("Found {api} API resource in database: {found}", name, result != null);

                return(result);
            }
        }
Beispiel #4
0
        public static async Task SetClientPropsAsync(this IdentityServerDriverProvider ext, Client client, IDictionary <string, string> properties)
        {
            ext = ext ?? throw new ArgumentNullException(nameof(ext));

            string clientId = client?.ClientId ?? throw new ArgumentNullException(nameof(client));

            List <Neo4jProperty> props = properties?.Select(p => new Neo4jProperty()
            {
                Name = p.Key, Value = p.Value
            }).ToList() ?? new List <Neo4jProperty>();

            if (props.Count == 0)
            {
                throw new ArgumentException("No item to set");
            }

            using (ISession session = ext.GetDriver().Session())
            {
                Node n   = new Node(type: typeof(Neo4jClient));
                Node p   = new Node(type: typeof(Neo4jProperty));
                Rel  rel = new Rel(type: typeof(Relationships.Has));

                await session.RunAsync(
                    $"MATCH (n{n.Labels} {{{nameof(Client.ClientId)}:${nameof(clientId)}}}) " +
                    $"OPTIONAL MATCH (n)-{rel}->(p{p.Labels}) " +
                    $"WITH n, collect(p) AS olds " +
                    $"UNWIND ${nameof(props)} AS row " +
                    $"CREATE (n)-{rel}->(q{p.Labels}) " +
                    $"SET q+=row,q.{nameof(IGraphEntity.EntityId)}=id(q), q :{typeof(Neo4jProperty).Name} " +
                    $"WITH olds " +
                    $"UNWIND olds AS old " +
                    $"DETACH DELETE old",
                    new { clientId, props });
            }
        }
Beispiel #5
0
 public static HTMLBuilder <X, Y> Rel <X, Y>(this HTMLBuilder <X, Y> builder, Rel rel)
     where X : Tag, SupportRelAttribute
     where Y : HTMLBuilder
 {
     builder.CurrentTag.AddRel(rel);
     return(builder);
 }
Beispiel #6
0
        public static async Task ReplaceClientClaimAsync(this IdentityServerDriverProvider ext, Client client, string type, string value)
        {
            ext = ext ?? throw new ArgumentNullException(nameof(ext));
            if (string.IsNullOrEmpty(type))
            {
                throw new ArgumentNullException(nameof(type));
            }
            value = value ?? throw new ArgumentNullException(nameof(value));

            string clientId = client?.ClientId ?? throw new ArgumentNullException(nameof(client));

            using (ISession session = ext.GetDriver().Session())
            {
                Node n   = new Node(type: typeof(Neo4jClient));
                Node p   = new Node(type: typeof(Neo4jClaim));
                Rel  rel = new Rel(type: typeof(Relationships.Has));

                await session.RunAsync(
                    $"MATCH (n{n.Labels} {{{nameof(Client.ClientId)}:${nameof(clientId)}}})" +
                    $"-{rel}->" +
                    $"(p{p.Labels} {{{nameof(Neo4jClaim.ClaimType)}:${nameof(type)}}}) " +
                    $"SET p.{nameof(Neo4jClaim.ClaimValue)}=${nameof(value)}",
                    new { clientId, type, value });
            }
        }
Beispiel #7
0
        public static async Task <IEnumerable <Client> > GetAllClientsAsync(this IdentityServerDriverProvider ext)
        {
            ext = ext ?? throw new ArgumentNullException(nameof(ext));

            using (ISession session = ext.GetDriver().Session())
            {
                Node cli    = new Node(type: typeof(Client));
                Node prop   = new Node(type: typeof(Neo4jProperty));
                Node secret = new Node(type: typeof(Secret));
                Node claim  = new Node(type: typeof(Neo4jClaim));
                Rel  rel    = new Rel(type: typeof(Relationships.Has));

                List <Client> result = await session.AsAsync(s =>
                                                             s.ExecuteQuery <Client, IEnumerable <Neo4jProperty>, IEnumerable <Neo4jSecret>, IEnumerable <Neo4jClaim> >(
                                                                 $"MATCH (c{cli.Labels}) " +
                                                                 $"OPTIONAL MATCH (c)-{rel}->(p{prop.Labels}) " +
                                                                 $"OPTIONAL MATCH (c)-{rel}->(s{secret.Labels}) " +
                                                                 $"OPTIONAL MATCH (c)-{rel}->(cl{claim.Labels}) " +
                                                                 $"WITH c, p, s, cl ORDER BY id(c), id(p), id(s), id(cl) " +
                                                                 $"WITH c, {{props: collect(distinct p), secs:collect(distinct s), cls:collect(distinct cl)}} AS val " +
                                                                 $"WITH c, val.props AS p, val.secs AS s, val.cls AS cl ORDER BY id(c) " +
                                                                 $"RETURN c, p, s, cl",
                                                                 (client, props, secrets, claims) =>
                {
                    client.Properties = props?.ToDictionary(p => p.Name, p => p.Value);
                    client.Claims = claims?.Select(p => p.ToClaim())?.ToList();
                    client.ClientSecrets = secrets?.Select(p => p as Secret)?.ToList();
                    return(client);
                })
                                                             .ToList());

                return(result);
            }
        }
Beispiel #8
0
 public void RelArrayCtorTest()
 {
     var token = new Word("<=", Tag.LE);
     var exp1  = new Id(new Word("x", Tag.ID), new Array(2, VarType.INT), 0);
     var exp2  = new Id(new Word("y", Tag.ID), new Array(2, VarType.INT), 0);
     var rel   = new Rel(token, exp1, exp2);
 }
Beispiel #9
0
 public void RelNotSameCtorTest()
 {
     var token      = new Word("<=", Tag.LE);
     var variable   = new Id(new Word("x", Tag.ID), VarType.INT, 0);
     var expression = new Expr(new Token(32), VarType.BOOL);
     var rel        = new Rel(token, variable, expression);
 }
Beispiel #10
0
        public static async Task SetClientSecretsAsync(this IdentityServerDriverProvider ext, Client client, IEnumerable <Secret> secrets)
        {
            ext = ext ?? throw new ArgumentNullException(nameof(ext));

            string clientId = client?.ClientId ?? throw new ArgumentNullException(nameof(client));

            List <Secret> newSecrets = secrets?.ToList() ?? new List <Secret>();

            if (newSecrets.Count == 0)
            {
                throw new ArgumentException("No item to set");
            }

            using (ISession session = ext.GetDriver().Session())
            {
                Node n   = new Node(type: typeof(Neo4jClient));
                Node p   = new Node(type: typeof(Neo4jSecret));
                Rel  rel = new Rel(type: typeof(Relationships.Has));

                await session.RunAsync(
                    $"MATCH (n{n.Labels} {{{nameof(Client.ClientId)}:${nameof(clientId)}}}) " +
                    $"OPTIONAL MATCH (n)-{rel}->(p{p.Labels}) " +
                    $"WITH n, collect(p) AS olds " +
                    $"UNWIND ${nameof(newSecrets)} AS row " +
                    $"CREATE (n)-{rel}->(q{p.Labels}) " +
                    $"SET q+=row,q.{nameof(IGraphEntity.EntityId)}=id(q), q :{typeof(Neo4jSecret).Name} " +
                    $"WITH olds " +
                    $"UNWIND olds AS old " +
                    $"DETACH DELETE old",
                    new { clientId, newSecrets });
            }
        }
Beispiel #11
0
        public static async Task AddPersistedGrantAsync(this IdentityServerDriverProvider ext, PersistedGrant grant)
        {
            ext   = ext ?? throw new ArgumentNullException(nameof(ext));
            grant = grant ?? throw new ArgumentNullException(nameof(grant));

            using (ISession session = ext.GetDriver().Session())
            {
                Node n   = new Node(type: typeof(Neo4jPersistedGrant));
                Node c   = new Node(type: typeof(Client));
                Rel  rel = new Rel(type: typeof(Relationships.Has));

                Neo4jPersistedGrant newGrant = await session.AsAsync(s =>
                                                                     s.ExecuteQuery <Neo4jPersistedGrant>(
                                                                         $"MATCH (c{c.Labels} {{{nameof(Client.ClientId)}:${nameof(grant)}.{nameof(grant.ClientId)}}}) " +
                                                                         $"CREATE (c)" +
                                                                         $"-{rel}->" +
                                                                         $"(p{n.Labels}) " +
                                                                         $"SET p+=${nameof(grant)}, p.{nameof(IGraphEntity.EntityId)}=id(p), p :{typeof(Neo4jPersistedGrant).Name} RETURN p",
                                                                         new { grant }).FirstOrDefault());

                if (grant is IGraphEntity)
                {
                    (grant as IGraphEntity).EntityId = newGrant.EntityId;
                }
            }
        }
Beispiel #12
0
        public static async Task SetApiResourceScopesAsync(this IdentityServerDriverProvider ext, ApiResource resource, IEnumerable <Scope> scopes)
        {
            ext = ext ?? throw new ArgumentNullException(nameof(ext));

            string name = resource?.Name ?? throw new ArgumentNullException(nameof(resource));

            List <Scope> newScopes = scopes?.ToList() ?? new List <Scope>();

            if (newScopes.Count == 0)
            {
                throw new ArgumentException("No item to set");
            }

            using (ISession session = ext.GetDriver().Session())
            {
                Node n   = new Node(type: typeof(Neo4jApiResource));
                Node p   = new Node(type: typeof(Neo4jScope));
                Rel  rel = new Rel(type: typeof(Relationships.Has));

                await session.RunAsync(
                    $"MATCH (n{n.Labels} {{{nameof(Resource.Name)}:${nameof(name)}}}) " +
                    $"OPTIONAL MATCH (n)-{rel}->(p{p.Labels}) " +
                    $"WITH n, collect(p) AS olds " +
                    $"UNWIND ${nameof(newScopes)} AS row " +
                    $"CREATE (n)-{rel}->(q{p.Labels}) " +
                    $"SET q+=row,q.{nameof(IGraphEntity.EntityId)}=id(q), q :{typeof(Neo4jScope).Name} " +
                    $"WITH olds " +
                    $"UNWIND olds AS old " +
                    $"DETACH DELETE old",
                    new { name, newScopes });
            }
        }
Beispiel #13
0
 public void Format(IPaperContext context, IObjectFactory factory, Entity entity)
 {
     if (Rel?.Any() != true)
     {
         this.AddRel(RelNames.Link);
     }
 }
        /// <summary>
        /// Finds a client by id
        /// </summary>
        /// <param name="clientId">The client id</param>
        /// <returns>
        /// The client
        /// </returns>
        public async Task <Client> FindClientByIdAsync(string clientId)
        {
            using (ISession session = _context.GetDriver().Session())
            {
                Node cli    = new Node(type: typeof(Client));
                Node prop   = new Node(type: typeof(Neo4jProperty));
                Node secret = new Node(type: typeof(Secret));
                Node claim  = new Node(type: typeof(Neo4jClaim));
                Rel  rel    = new Rel(type: typeof(Relationships.Has));

                Client result = await session.AsAsync(s =>
                                                      s.ExecuteQuery <Client, IEnumerable <Neo4jProperty>, IEnumerable <Secret>, IEnumerable <Neo4jClaim> >(
                                                          $"MATCH (c{cli.Labels} {{{nameof(Client.ClientId)}:${nameof(clientId)}}}) " +
                                                          $"OPTIONAL MATCH (c)-{rel}->(p{prop.Labels}) " +
                                                          $"OPTIONAL MATCH (c)-{rel}->(s{secret.Labels}) " +
                                                          $"OPTIONAL MATCH (c)-{rel}->(cl{claim.Labels}) " +
                                                          $"WITH c, p, s, cl ORDER BY id(c), id(p), id(s), id(cl) " +
                                                          $"WITH c, {{props: collect(distinct p), secs:collect(distinct s), cls:collect(distinct cl)}} AS val " +
                                                          $"WITH c, val.props AS p, val.secs AS s, val.cls AS cl ORDER BY id(c) " +
                                                          $"RETURN c, p, s, cl",
                                                          (client, props, secrets, claims) =>
                {
                    client.Properties = props?.ToDictionary(p => p.Name, p => p.Value);
                    client.Claims = claims?.Select(p => p.ToClaim())?.ToList();
                    client.ClientSecrets = secrets?.Select(p => p as Secret)?.ToList();
                    return(client);
                },
                                                          new { clientId })
                                                      .FirstOrDefault());

                _logger.LogDebug("{clientId} found in database: {clientIdFound}", clientId, result != null);

                return(result);
            }
        }
Beispiel #15
0
        public void IfCtorTest()
        {
            var variable = new Id(new Word("x", Tag.ID), VarType.INT, 0);
            var constant = new Constant(new Num(12), VarType.INT);
            var expresion = new Rel(Word.EQ, variable, constant);

            var ifnode = new If(expresion, new Stmt());
        }
Beispiel #16
0
 public CJUMP(Rel rel, Expr left, Expr right, Label t, Label f)
 {
     Relop   = rel;
     Left    = left;
     Right   = right;
     IfTrue  = t;
     IfFalse = f;
 }
Beispiel #17
0
        public static string ToRelString(this Rel relation)
        {
            //UglyPatch
            var str = relation == Rel._None
                ? string.Empty
                : string.Join("-", Regex.Split(relation.ToString().Replace(",", ""), "(?<=[a-z])(?=[A-Z])")).ToLower();

            return(string.Join(" ", str.Split(' ').Where(x => !x.StartsWith("_"))));
        }
Beispiel #18
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Rel?.GetHashCode() ?? 0;
         hashCode = (hashCode * 397) ^ (Href?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Title?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Beispiel #19
0
        public void TestRel()
        {
            var isLess = new Rel(new Token('<'), new Constant(10), new Constant(100));

            Assert.AreEqual("10 < 100", isLess.ToString());

            isLess.Jumping(42, 99);
            //output:
            //        if 10 < 100 goto L42
            //        goto L99
        }
Beispiel #20
0
        Expr equality()
        {
            Expr x = rel();

            while (look.tag == Tag.EQ || look.tag == Tag.NE)
            {
                Token tok = look;
                move();
                x = new Rel(tok, x, rel(), compileRows);
            }
            return(x);
        }
Beispiel #21
0
        public void RelCtorTest()
        {
            var token    = new Word("<=", Tag.LE);
            var variable = new Id(new Word("x", Tag.ID), VarType.INT, 0);
            var intnode  = new Constant(3);
            var rel      = new Rel(token, variable, intnode);

            Assert.AreSame(variable, rel.Expr1);
            Assert.AreSame(intnode, rel.Expr2);
            Assert.AreSame(token, rel.Op);
            Assert.AreSame(VarType.BOOL, rel.Type);
        }
Beispiel #22
0
        internal virtual Expr equality()
        {
            Expr x = rel();

            while (look.tag == Tag.EQ || look.tag == Tag.NE)
            {
                Token tok = look;
                move();
                x = new Rel(tok, x, rel());
            }
            return(x);
        }
Beispiel #23
0
        private Expr EqualityExpr()
        {
            var x = RelExpr();

            while (_look.Tag == Tag.EQ || _look.Tag == Tag.NE)
            {
                var tok = _look;
                Move();
                x = new Rel(tok, x, RelExpr());
            }
            return(x);
        }
Beispiel #24
0
 public RelOp(LatteParser.ERelOpContext context) :
     base(context.expr()[0], context.expr()[1])
 {
     Rel = context.relOp() switch
     {
         LatteParser.LessThanContext _ => Rel.LessThan,
                                     LatteParser.LessEqualsContext _ => Rel.LessEquals,
                                     LatteParser.GreaterThanContext _ => Rel.GreaterThan,
                                     LatteParser.GreaterEqualsContext _ => Rel.GreaterEquals,
                                     LatteParser.EqualsContext _ => Rel.Equals,
                                     LatteParser.NotEqualsContext _ => Rel.NotEquals
     };
 }
Beispiel #25
0
        protected void Init(RelNode value)
        {
            var equal  = value.Heading.IsEqual(Heading);
            var compat = equal || value.Heading.IsCompatible(Heading);

            if (!compat)
            {
                throw Error.Fatal($"headings are not compatible: <{value.Heading}> and <{Heading}>");
            }
            var map = Heading.CreateMap(value.Heading);

            Value = Rel.Create(value.Select(t => RelStatic.CreateByMap <T>(t, map)));
        }
Beispiel #26
0
        public static double fromEnum(Rel num)
        {
            switch (num)
            {
                case Rel.Required: return required;
                case Rel.Strong: return strong;
                case Rel.Medium: return medium;
                case Rel.Weak: return weak;

            }

            return 0;
        }
Beispiel #27
0
 public bool next()
 {
     i++;
     if (i < 0 || i >= _rels.Length)
     {
         rel = _outerInstance.NO_REL;
         return(false);
     }
     else
     {
         rel = _rels[i];
         return(true);
     }
 }
        private Relation ToRelation(Rel rel)
        {
            Relation relation = new Relation(rel.Name, null, EnabledFlag.False);

            foreach (var col in rel.Columns)
            {
                relation.RelationColumns.Add(new RelationColumn(col));
            }
            foreach (var relRow in rel.Rows)
            {
                relation.AddRelationRow(relRow.Value.ToArray());
            }
            return(relation);
        }
        public void CreateSalesValidityRelation(string modelName, List <Characteristic> characteristics, Dictionary <string, Dictionary <string, Characteristic> > variantCharacteristics)
        {
            var generalGroup = GetGeneralGroup();
            var rel          = new Rel($"SalesValidity_{modelName}");

            rel.Columns.Add($"{generalGroup.Name}.GEN_S_MODEL");
            rel.Columns.Add($"{generalGroup.Name}.GEN_S_VARIANT");

            var variants = variantCharacteristics.Keys.ToList();

            // initialize a row for every variant
            foreach (var variant in variants)
            {
                rel.Rows.Add(variant, new List <string> {
                    $"\"{modelName}\"", $"\"{variant}\""
                });
            }
            var lookup = characteristics.ToDictionary(c => c.Name);

            foreach (var variable in GetVariables())
            {
                if (lookup.ContainsKey(variable.Name))
                {
                    rel.Columns.Add($"{generalGroup.Name}.{variable.Name}");
                    foreach (var variant in variants)
                    {
                        if (variantCharacteristics[variant].TryGetValue(variable.Name, out var characteristic))
                        {
                            rel.Rows[variant].Add("=" + characteristic.Values.Select(v => $"\"{v}\"").Aggregate((r, l) => $"{r},{l}"));
                        }
                        else
                        {
                            rel.Rows[variant].Add("=\"N.A.\"");
                        }
                    }
                }
                else
                {
                    if (variable.Name != "GEN_S_MODEL" && variable.Name != "GEN_S_VARIANT")
                    {
                        variable.PropertyValues.Add(new PropertyValue("Show", false));
                    }
                }
            }
            var relation = ToRelation(rel);

            relation.PropertyValues.Add(new PropertyValue("Enabled", true));
            generalGroup.AddRelation(relation);
        }
Beispiel #30
0
        /// <summary>
        /// Removes all grants of a give type for a given subject id and client id combination.
        /// </summary>
        /// <param name="subjectId">The subject identifier.</param>
        /// <param name="clientId">The client identifier.</param>
        /// <param name="type">The type.</param>
        /// <returns></returns>
        public async Task RemoveAllAsync(string subjectId, string clientId, string type)
        {
            using (ISession session = _context.GetDriver().Session())
            {
                Node c   = new Node(type: typeof(Client));
                Node n   = new Node(type: typeof(PersistedGrant));
                Rel  rel = new Rel(type: typeof(Relationships.Has));

                IResultSummary summary = await(await session.RunAsync(
                                                   $"MATCH (c{c.Labels} {{{nameof(Client.ClientId)}:${nameof(clientId)}}})" +
                                                   $"-{rel}->" +
                                                   $"(n{n.Labels} {{{nameof(PersistedGrant.ClientId)}:${nameof(clientId)},{nameof(PersistedGrant.SubjectId)}:${nameof(subjectId)},{nameof(PersistedGrant.Type)}:${nameof(type)}}}) " +
                                                   $"DETACH DELETE n"
                                                   , new { clientId, subjectId, type })).SummaryAsync();
            }
        }
Beispiel #31
0
 public static Rel NotRel(Rel relop)
 {
     switch (relop)
     {
         case Rel.Equal:
             return Rel.NotEqual;
         case Rel.NotEqual:
             return Rel.Equal;
         case Rel.LessThan:
             return Rel.GreaterEqual;
         case Rel.GreaterEqual:
             return Rel.LessThan;
         case Rel.GreaterThan:
             return Rel.LessEqual;
         case Rel.LessEqual:
             return Rel.GreaterThan;
         case Rel.UnsignedLT:
             return Rel.UnsignedGE;
         case Rel.UnsignedGE:
             return Rel.UnsignedLT;
         case Rel.UnsignedGT:
             return Rel.UnsignedLE;
         case Rel.UnsignedLE:
             return Rel.UnsignedGT;
         default:
             throw new FatalError("No such relop in CJUMP.NotRel()");
             break;
     }
     return 0;
 }
Beispiel #32
0
 public CJUMP(Rel rel, Expr left, Expr right, Label t, Label f)
 {
     Relop = rel;
     Left = left;
     Right = right;
     IfTrue = t;
     IfFalse = f;
 }