Example #1
0
 public PartialStaticCall(int[] mappings, PValue[] closedArguments, PCall call,
     string memberId, PType ptype) : base(mappings, closedArguments, 0)
 {
     _ptype = ptype;
     _call = call;
     _memberId = memberId;
 }
Example #2
0
    /// <summary>First half builds the ring, second half tests the connection handler...</summary>
    public void RingTest() {
      Parameters p = new Parameters("Test", "Test");
      string[] args = "-b=.2 -c --secure_senders -s=50".Split(' ');
      Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage);
      Simulator sim = new Simulator(p);
      _sim = sim;
      Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring");

      SimpleTimer.RunSteps(fifteen_mins, false);
      var nm0 = sim.TakenIDs.Values[0];
      int idx = 1;
      NodeMapping nm1 = null;
      do {
        nm1 = sim.TakenIDs.Values[idx++];
      } while(Simulator.AreConnected(nm0.Node, nm1.Node) && idx < sim.TakenIDs.Count);

      Assert.IsFalse(Simulator.AreConnected(nm0.Node, nm1.Node), "Sanity check");
      var ptype = new PType("chtest");
      var ch0 = new ConnectionHandler(ptype, (StructuredNode) nm0.Node);
      var ch1 = new ConnectionHandler(ptype, (StructuredNode) nm1.Node);
      ConnectionHandlerTest(nm0.Node, nm1.Node, ch0, ch1);

      SimpleTimer.RunSteps(fifteen_mins * 2, false);

      Assert.IsFalse(Simulator.AreConnected(nm0.Node, nm1.Node), "Sanity check0");
      ptype = new PType("chtest1");
      ch0 = new SecureConnectionHandler(ptype, (StructuredNode) nm0.Node, nm0.Sso);
      ch1 = new SecureConnectionHandler(ptype, (StructuredNode) nm1.Node, nm1.Sso);
      ConnectionHandlerTest(nm0.Node, nm1.Node, ch0, ch1);
    }
 public VariableDescription(AALocalDecl localDecl, VariableTypes type)
 {
     Name = localDecl.GetName().Text;
     Type = Util.TypeToString(localDecl.GetType());
     switch (type)
     {
         case VariableTypes.LocalVariable:
             PlacementPrefix = "Local";
             break;
         case VariableTypes.Parameter:
             PlacementPrefix = "Parameter";
             break;
         case VariableTypes.StructVariable:
             PlacementPrefix = "Struct field";
             break;
         default:
             PlacementPrefix = "";
             break;
     }
     VariableType = type;
     Const = localDecl.GetConst() != null;
     IsStatic = localDecl.GetStatic() != null;
     Visibility = localDecl.GetVisibilityModifier();
     realType = (PType) localDecl.GetType().Clone();
     init = localDecl.GetInit();
     Line = localDecl.GetName().Line;
     Position = TextPoint.FromCompilerCoords(localDecl.GetName());
 }
Example #4
0
 public TableView(string path_name, PType e_type)
 {
     tp_rec = new PTypeRecord(
         new NamedType("deleted", new PType(PTypeEnumeration.boolean)),
         new NamedType("evalue", e_type));
     table_cell = new PaCell(new PTypeSequence(tp_rec), path_name + ".pac", false);
 }
 public TypedefDescription(ATypedefDecl typeDef)
 {
     Name = ((ANamedType) typeDef.GetName()).AsString();
     Snapshot = typeDef;
     typeDef.Parent().RemoveChild(typeDef);
     Position = TextPoint.FromCompilerCoords(typeDef.GetToken());
     realType = typeDef.GetType();
 }
Example #6
0
 public MCustomer(int id, string fName, string lName, string address, string country,
     string phone, string email, ICollection<MLogInfo> logInfos,
     PType pType, MDiscountGroup discountGroup, string payStatus)
     : base(id, fName, lName, address, country, phone, email, logInfos, pType)
 {
     DiscountGroup = discountGroup;
     PaymentStatus = payStatus;
 }
Example #7
0
 public BaseMove(string name, PType t, Category c, int initPP, int p, int a, int range = 1)
 {
     Name = name;
     MoveType = t;
     MoveCategory = c;
     BasePP = initPP;
     Power = p;
     Accuracy = a;
 }
Example #8
0
 public SerialBuffer(ISerialFlow output, int slevel = 0)
 {
     this.typ = output.Type;
     this.output = output;
     //this.zstack = new ZElement[10000000];
     //this.inputStack.Push(new TBStack(typ, zpointer));
     this.inputStack.Push(new TBStack(typ));
     this.slevel = slevel;
     this.currentTreeDepth = slevel;
 }
Example #9
0
 // called my manager
 public void initialize(ProjectileManager manager, PType type) {
     mesh = transform.Find("Model").gameObject;
     col = GetComponent<Collider>();
     rb = GetComponent<Rigidbody>();
     psem = transform.Find("Particles").GetComponent<ParticleSystem>().emission;
     lightComp = GetComponent<Light>();
     this.manager = manager;
     this.type = type;
     freeze = false;
     reset();
 }
Example #10
0
  public bool HandleReply(ReqrepManager man, ReqrepManager.ReqrepType rt,
		   int mid,
		   PType prot,
		   MemBlock payload,
		   ISender from,
		   ReqrepManager.Statistics s,
		   object state)
  {
    Console.WriteLine("{0} got our message", from);
    return false;
  }
Example #11
0
    public Projectile getProjectile(PType type) {
        List<Projectile> list = poolLookup[type];
        if (list.Count <= 0) {
            buildProjectile(type);
        }

        int last = list.Count - 1;
        Projectile p = list[last];
        list.RemoveAt(last);
        p.gameObject.SetActive(true);
        return p;
    }
Example #12
0
 public static Project Create(string Profolder, string Proname, PType Protype, bool Inctemplate)
 {
     Project PObject ;
     string Profile = Profolder + @"\" + Proname + @"\" + Proname + ".mpr";
     Profolder = Profolder + @"\" + Proname;
     switch (Protype) {
         case PType.Csharp:
             PObject = new Csharp(Profile);
             break;
         case PType.Databse:
             PObject = new Database(Profile);
             break;
         case PType.Hydro:
             PObject = new Hydro(Profile);
             break;
         case PType.Ilasm:
             PObject = new Ilasm(Profile);
             break;
         case PType.Java:
             PObject = new Java(Profile);
             break;
         case PType.Unmanaged:
             PObject = new Unmanaged(Profile);
             break;
         case PType.Vbasic:
             PObject = new Vbasic(Profile);
             break;
         case PType.Website:
             PObject = new Website(Profile);
             break;
         case PType.Yalamof:
             PObject = new Yalamof(Profile);
             break;
         default:
             PObject = new Unmanaged();
             break;
     }
     try
     {
         Directory.CreateDirectory(Profolder);
         if (Inctemplate == true)
         {
             PObject.CopyTemplate();
         }
         PObject.Save();
     }
     catch (Exception e)
     {
         Exceptioner.Log(e);
     }
     return PObject;
 }
 private DynamicMetaObject GetEvent(DynamicMetaObject target, PType pType)
 {
     var eventName = Name + "された";
     EventInfo evInfo = null;
     var evs = pType.GetEventNames();
     pType.TryGetEvent(eventName, out evInfo);
     if (evInfo == null)
         return null;
     var ctorInfo = typeof(AddEventDelegator).GetConstructor(new[] { typeof(object), typeof(EventInfo) });
     return new DynamicMetaObject(
         Expression.New(ctorInfo, target.Expression, Expression.Constant(evInfo)),
         BindingRestrictions.GetTypeRestriction(target.Expression, target.LimitType));
 }
 public VariableDescription(ATriggerDecl triggerDecl)
 {
     Name = triggerDecl.GetName().Text;
     Type = "trigger";
     PlacementPrefix = "Field";
     VariableType = VariableTypes.Field;
     Const = false;
     IsStatic = false;
     realType = new ANamedType(new TIdentifier("trigger"), null);
     Visibility = (PVisibilityModifier)triggerDecl.GetVisibilityModifier().Clone();
     Line = triggerDecl.GetName().Line;
     Position = TextPoint.FromCompilerCoords(triggerDecl.GetActionsToken());
 }
Example #15
0
 // constructor
 public MPerson(int id, string fName, string lName, string address, string country,
     string phone, string email, ICollection<MLogInfo> logInfos, PType pType)
 {
     ID = id;
     FName = fName;
     LName = lName;
     Address = address;
     Country = country;
     Phone = phone;
     Email = email;
     LogInfos = logInfos;
     PersonType = pType;
 }
 public VariableDescription(AFieldDecl fieldDecl)
 {
     Name = fieldDecl.GetName().Text;
     Type = Util.TypeToString(fieldDecl.GetType());
     PlacementPrefix = "Field";
     VariableType = VariableTypes.Field;
     Const = fieldDecl.GetConst() != null;
     IsStatic = fieldDecl.GetStatic() != null;
     Visibility = fieldDecl.GetVisibilityModifier();
     realType = (PType)fieldDecl.GetType().Clone();
     init = fieldDecl.GetInit();
     Line = fieldDecl.GetName().Line;
     Position = TextPoint.FromCompilerCoords(fieldDecl.GetName());
 }
 private DynamicMetaObject GetProperty(DynamicMetaObject target, PType pType)
 {
     PPropertyInfo propInfo = null;
     pType.TryGetPropertyInfo(Name, out propInfo);
     if (propInfo == null)
         return null;
     return new DynamicMetaObject(
         Expression.Call(
             Expression.Constant(pType),
             MethodInfo,
             Expression.Constant(propInfo),
             Expression.Convert(target.Expression, InstanceType)),
         BindingRestrictions.GetTypeRestriction(target.Expression, target.LimitType));
 }
Example #18
0
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PType pType = await db.PTypes.FindAsync(id);

            if (pType == null)
            {
                return(HttpNotFound());
            }
            return(View(pType));
        }
Example #19
0
        public ReqrepManager(object info, PType prefix)
        {
            ReqrepManager existing;

            lock ( _inst_tab_sync ) {
                if (_instance_table.TryGetValue(info, out existing))
                {
                    throw new Exception("Already an existing ReqrepManager for: " + info.ToString());
                }
                else
                {
                    _instance_table[info] = this;
                }
            }
            _info = info.ToString();

            _prefix            = prefix;
            _req_handler_table = new Hashtable();
            Random r = new Random();

            //Don't use negative numbers:
            _req_state_table = new UidGenerator <RequestState>(r, true);
            //Don't use negative numbers:
            _reply_id_table    = new UidGenerator <ReplyState>(r, true);
            _rep_handler_table = new Hashtable();

            /**
             * We keep a list of the most recent 1000 replies until they
             * get too old.  If the reply gets older than reptimeout, we
             * remove it
             */
            _reply_cache = new Cache(1000);
            _reply_cache.EvictionEvent += HandleReplyCacheEviction;

            /*
             * Here we set the timeout mechanisms.  There is a default
             * value, but this is now dynamic based on the observed
             * RTT of the network
             */
            //resend the request after 5 seconds.
            _edge_reqtimeout    = new TimeSpan(0, 0, 0, 0, 5000);
            _nonedge_reqtimeout = new TimeSpan(0, 0, 0, 0, 5000);
            //Start with 50 sec timeout
            _acked_reqtimeout = new TimeSpan(0, 0, 0, 0, 50000);
            //Here we track the statistics to improve the timeouts:
            _nonedge_rtt_stats = new TimeStats(_nonedge_reqtimeout.TotalMilliseconds, 0.98);
            _edge_rtt_stats    = new TimeStats(_edge_reqtimeout.TotalMilliseconds, 0.98);
            _acked_rtt_stats   = new TimeStats(_acked_reqtimeout.TotalMilliseconds, 0.98);
            _last_check        = DateTime.UtcNow;
        }
Example #20
0
        public override void TranslateDictionaryGet(StringBuilder sb, Expression dictionary, Expression key)
        {
            PType dictionaryType = dictionary.ResolvedType;

            sb.Append("Dictionary_get_");
            sb.Append(this.Platform.TranslateType(dictionaryType.Generics[0]));
            sb.Append("_to_");
            sb.Append(this.Platform.TranslateType(dictionaryType.Generics[1]));
            sb.Append("(");
            this.TranslateExpression(sb, dictionary);
            sb.Append(", ");
            this.TranslateExpression(sb, key);
            sb.Append(')');
        }
Example #21
0
 public VariableDescription(AFieldDecl fieldDecl)
 {
     Name            = fieldDecl.GetName().Text;
     Type            = Util.TypeToString(fieldDecl.GetType());
     PlacementPrefix = "Field";
     VariableType    = VariableTypes.Field;
     Const           = fieldDecl.GetConst() != null;
     IsStatic        = fieldDecl.GetStatic() != null;
     Visibility      = fieldDecl.GetVisibilityModifier();
     realType        = (PType)fieldDecl.GetType().Clone();
     init            = fieldDecl.GetInit();
     Line            = fieldDecl.GetName().Line;
     Position        = TextPoint.FromCompilerCoords(fieldDecl.GetName());
 }
Example #22
0
        private string GetDictionaryKeyType(PType type)
        {
            switch (type.RootValue)
            {
            case "int":
                return("int");

            case "string":
                return("str");

            default:
                throw new Exception("Invalid key type for dictionary.");
            }
        }
Example #23
0
        private void MakeAssignments(AABlock block, PType type, PLvalue leftSide, bool onEnhritedFields)
        {
            if (type is ANamedType && data.StructTypeLinks.ContainsKey((ANamedType)type))
            {
                AStructDecl str = data.StructTypeLinks[(ANamedType)type];
                foreach (AALocalDecl field in str.GetLocals().OfType <AALocalDecl>())
                {
                    if (!onEnhritedFields && data.EnheritanceLocalMap.ContainsKey(field))
                    {
                        continue;
                    }

                    ALvalueExp lvalueExp = new ALvalueExp(Util.MakeClone(leftSide, data));
                    data.ExpTypes[lvalueExp] = data.LvalueTypes[leftSide];
                    AStructLvalue newLeftSide = new AStructLvalue(lvalueExp, new ADotDotType(new TDot(".")), new TIdentifier(field.GetName().Text));
                    data.StructFieldLinks[newLeftSide] = field;
                    data.LvalueTypes[newLeftSide]      = field.GetType();

                    if (field.GetInit() != null)
                    {
                        AAssignmentExp assignment = new AAssignmentExp(new TAssign("="), newLeftSide,
                                                                       Util.MakeClone(field.GetInit(), data));
                        data.ExpTypes[assignment] = data.LvalueTypes[newLeftSide];

                        block.GetStatements().Add(new AExpStm(new TSemicolon(";"),
                                                              assignment));
                    }
                    else
                    {
                        MakeAssignments(block, field.GetType(), newLeftSide, onEnhritedFields);
                    }
                }
            }
            else if (type is AArrayTempType)
            {
                AArrayTempType aType = (AArrayTempType)type;
                for (int i = 0; i < int.Parse(aType.GetIntDim().Text); i++)
                {
                    AIntConstExp index = new AIntConstExp(new TIntegerLiteral(i.ToString()));
                    data.ExpTypes[index] = new ANamedType(new TIdentifier("int"), null);

                    ALvalueExp lvalueExp = new ALvalueExp(Util.MakeClone(leftSide, data));
                    data.ExpTypes[lvalueExp] = data.LvalueTypes[leftSide];
                    AArrayLvalue newLeftSide = new AArrayLvalue(new TLBracket("["), lvalueExp, index);
                    data.LvalueTypes[newLeftSide] = aType.GetType();

                    MakeAssignments(block, aType.GetType(), newLeftSide, onEnhritedFields);
                }
            }
        }
        public PoisonType(PType type) : base("")
        {
            string variable;

            this.poisonType = type;
            if (poisonType == PType.Malignant)
            {
                variable = "Malignant";
            }
            else
            {
                variable = "Resilient";
            }
            this.variable = variable;
        }
Example #25
0
        public ConnectionHandler(PType ptype, StructuredNode node)
        {
            _node     = node;
            _ondemand = new OnDemandConnectionOverlord(node);
            _node.AddConnectionOverlord(_ondemand);
            _ptype             = ptype;
            _ptype_mb          = ptype.ToMemBlock();
            _address_to_sender = new Dictionary <Address, ISender>();
            _sender_to_address = new Dictionary <ISender, Address>();
            _con_to_csw        = new Dictionary <Connection, ConSenderWrapper>();

            node.GetTypeSource(_ptype).Subscribe(this, null);
            node.ConnectionTable.ConnectionEvent    += HandleConnection;
            node.ConnectionTable.DisconnectionEvent += HandleDisconnection;
        }
Example #26
0
        public IndexKeyImmutable(string path_name)
        {
            Type typ = typeof(Tkey);

            if (typ != typeof(int) && typ != typeof(long))
            {
                throw new Exception("Err: wrong type of key");
            }
            PType tp_key   = typ == typeof(int) ? new PType(PTypeEnumeration.integer) :  new PType(PTypeEnumeration.longinteger);
            PType tp_index = new PTypeSequence(new PTypeRecord(
                                                   new NamedType("key", tp_key),
                                                   new NamedType("offset", new PType(PTypeEnumeration.longinteger))));

            index_cell = new PaCell(tp_index, path_name + ".pac", false);
        }
        public EnrichmentDescription(AEnrichmentDecl structDecl)
        {
            Parser parser = new Parser(structDecl);

            Fields = parser.Fields;
            Methods = parser.Methods;
            Constructors = parser.Constructors;
            Deconstructors = parser.Deconstructors;
            LineFrom = structDecl.GetToken().Line;
            LineTo = structDecl.GetEndToken().Line;
            type = structDecl.GetType();
            type.Parent().RemoveChild(type);
            IsClass = structDecl.GetDimention() != null;
            Position = TextPoint.FromCompilerCoords(structDecl.GetToken());
        }
    public virtual IEnumerator AddToNucleusRoutine(float time, PType t)
    {
        yield return(new WaitForSeconds(time));

        if (t == PType.N)
        {
            this.nucleus.n++;
            this.nucleus.Rebuild();
        }
        else
        {
            this.nucleus.p++;
            this.nucleus.Rebuild();
        }
    }
Example #29
0
        /// <summary>Create a SubringEdgeListener.</summary>
        /// <param name="shared_node">The overlay used for the transport.</param>
        /// <param name="private_node">The overlay needing edges.</param>
        public SubringEdgeListener(Node shared_node, Node private_node)
        {
            _shared_node  = shared_node;
            _private_node = private_node;
            _it           = new IdentifierTable();

            _local_ta = new SubringTransportAddress(shared_node.Address as AHAddress,
                                                    shared_node.Realm);

            _ptype = new PType("ns:" + shared_node.Realm);
            shared_node.DemuxHandler.GetTypeSource(_ptype).Subscribe(this, null);

            _running = 0;
            _started = 0;
        }
        public void Open(bool readOnlyMode)
        {
            doublesCell = new PaCell(new PTypeSequence(new PType(PTypeEnumeration.real)), dataCellPath + "/doublesLiterals.pac", readOnlyMode);
            var pTypeString      = new PType(PTypeEnumeration.sstring);
            var pTypeStringsPair = new PTypeRecord(new NamedType("value", pTypeString),
                                                   new NamedType("add info", pTypeString));

            stringsCell      = new PaCell(new PTypeSequence(pTypeStringsPair), dataCellPath + "/stringsLiterals.pac", readOnlyMode);
            boolsCell        = new PaCell(new PTypeSequence(new PType(PTypeEnumeration.boolean)), dataCellPath + "/booleansLiterals.pac", readOnlyMode);
            typedObjectsCell = new PaCell(new PTypeSequence(pTypeStringsPair), dataCellPath + "/typedObjectsLiterals.pac", readOnlyMode);
            stringsArhive    = new Archive(dataCellPath + "/strings archive");
            var ptypeCode = new PTypeSequence(new PType(PTypeEnumeration.@byte));

            StringsArchedCell = new PaCell(new PTypeSequence(new PTypeRecord(new NamedType("string code", ptypeCode), new NamedType("lang code", ptypeCode))), dataCellPath + "/strings archive/binary data", false);
        }
        public EnrichmentDescription(AEnrichmentDecl structDecl)
        {
            Parser parser = new Parser(structDecl);

            Fields         = parser.Fields;
            Methods        = parser.Methods;
            Constructors   = parser.Constructors;
            Deconstructors = parser.Deconstructors;
            LineFrom       = structDecl.GetToken().Line;
            LineTo         = structDecl.GetEndToken().Line;
            type           = structDecl.GetType();
            type.Parent().RemoveChild(type);
            IsClass  = structDecl.GetDimention() != null;
            Position = TextPoint.FromCompilerCoords(structDecl.GetToken());
        }
Example #32
0
 public override void InitTypes()
 {
     tp_entity      = new PType(PTypeEnumeration.integer);
     tp_otriple_seq = new PTypeSequence(new PTypeRecord(
                                            new NamedType("subject", tp_entity),
                                            new NamedType("predicate", tp_entity),
                                            new NamedType("object", tp_entity)));
     // Тип для экономного выстраивания индекса s-p для dtriples
     tp_dtriple_spf = new PTypeSequence(new PTypeRecord(
                                            new NamedType("subject", tp_entity),
                                            new NamedType("predicate", tp_entity),
                                            new NamedType("offset", new PType(PTypeEnumeration.longinteger))));
     tp_entities_column = new PTypeSequence(tp_entity);
     tp_Data_column     = new PTypeSequence(new PType(PTypeEnumeration.longinteger));
 }
Example #33
0
        /// <summary>All messages for the SecurityOverlord come through this loop.
        /// It demuxes between Security, SecureData, and SecureControl packets, while
        /// the remaining packets are left to the default handler.</summary>
        override public void HandleData(MemBlock data, ISender return_path, object state)
        {
            MemBlock payload = null;
            PType    t       = null;

            try {
                t = PType.Parse(data, out payload);

                if (t.Equals(Security))
                {
                    HandleData(payload, return_path, null);
                }
                else if (t.Equals(SecureData))
                {
                    HandleData(payload, return_path);
                }
                else if (t.Equals(SecureControl))
                {
                    HandleControl(payload, return_path);
                }
                else if (t.Equals(PType.Protocol.ReqRep))
                {
                    _rrman.HandleData(payload, return_path, null);
                }
                else
                {
                    Edge edge = return_path as Edge;
                    if (edge != null && !(edge is Brunet.Security.Transport.SecureEdge))
                    {
                        throw new Exception("Insecure edge attempting to communicate with the node!");
                    }
                    Subscriber sub = _sub;
                    if (sub == null)
                    {
                        throw new Exception("No default handler... this won't do!");
                    }
                    _sub.Handle(data, return_path);
                }
            } catch (Exception e) {
                string ps = string.Empty;
                try {
                    ps = payload.GetString(System.Text.Encoding.ASCII);
                } catch { }
                ProtocolLog.WriteIf(ProtocolLog.SecurityExceptions, String.Format(
                                        "Security Packet Handling Exception, Type: {0}, From: {1}\n\tData: {2}\n\tException:{3}\n\tStack Trace:{4}",
                                        t, return_path, ps, e, new System.Diagnostics.StackTrace(true)));
            }
        }
Example #34
0
 public VectorIndex(string indexName, PType keyType, PaEntry table)
 {
     this.indexName = indexName;
     this.keyType   = keyType;
     this.table     = table;
     tp_intern      = new PTypeSequence(new PTypeRecord(
                                            new NamedType("deleted", new PType(PTypeEnumeration.boolean)),
                                            new NamedType("outoffset", new PType(PTypeEnumeration.longinteger)),
                                            new NamedType("key", keyType)));
     intern_cell = new PaCell(tp_intern, indexName + "_vind.pac", false);
     if (intern_cell.IsEmpty)
     {
         intern_cell.Fill(new object[0]);
     }
     key_index = new FreeIndex(indexName + "_v", intern_cell.Root, 2);
 }
Example #35
0
        private bool IsJavaPrimitiveTypeBoxed(PType type)
        {
            switch (type.RootValue)
            {
            case "int":
            case "double":
            case "bool":
            case "byte":
            case "object":
            case "char":
                return(true);

            default:
                return(false);
            }
        }
Example #36
0
    public Projectile getProjectile(PType type)
    {
        List <Projectile> list = poolLookup[type];

        if (list.Count <= 0)
        {
            buildProjectile(type);
        }

        int        last = list.Count - 1;
        Projectile p    = list[last];

        list.RemoveAt(last);
        p.gameObject.SetActive(true);
        return(p);
    }
Example #37
0
 public long AppendPObj(PType tp, object valu)
 {
     long off = this.freespace;
     this.SetOffset(off);
     this.Append(tp, valu);
     if (tp.HasNoTail)
     {
         this.freespace += tp.HeadSize;
     }
     else
     {
         this.freespace = this.fs.Position;
     }
     this.nElements += 1;
     return off;
 }
Example #38
0
        public ActionResult Type_Create([DataSourceRequest] DataSourceRequest request, PType type)
        {
            if (ModelState.IsValid)
            {
                var entity = new PType
                {
                    Title = type.Title
                };

                db.PType.Add(entity);
                db.SaveChanges();
                type.Id = entity.Id;
            }

            return(Json(new[] { type }.ToDataSourceResult(request, ModelState)));
        }
Example #39
0
        /// <summary>
        ///  Тип
        /// BTree<T> = empty^none,
        /// pair^{element: T, less: BTree<T>, more: BTree<T>};
        /// </summary>
        /// <param name="tpElement"></param>
        /// <returns></returns>
        private static PTypeUnion PTypeTree(PType tpElement)
        {
            var tpBtree = new PTypeUnion();

            tpBtree.Variants = new[]
            {
                new NamedType("empty", new PType(PTypeEnumeration.none)),
                new NamedType("pair", new PTypeRecord(
                                  new NamedType("element", tpElement),
                                  new NamedType("less", tpBtree),
                                  new NamedType("more", tpBtree),
                                  //1 - слева больше, -1 - справа больше.
                                  new NamedType("balance", new PType(PTypeEnumeration.integer))))
            };
            return(tpBtree);
        }
 public static int SizeOfType(PType type)
 {
     if (type.GetType() == typeof(ASingleType))
     {
         return(1);
     }
     if (type.GetType() == typeof(ADoubleType))
     {
         return(2);
     }
     if (type.GetType() == typeof(AQuadType))
     {
         return(4);
     }
     return(0);
 }
        private Paragraph ProcessPType(PType pType)
        {
            var paragraph = new Paragraph();

            paragraph.Inlines.Add(new Run()
            {
                Text = "    " + pType.Text ?? string.Empty
            });

            foreach (var item in pType.Items.AsNotNull())
            {
                paragraph.Inlines.Add(ProcessBaseItems(item));
            }

            return(paragraph);
        }
Example #42
0
        // TODO: Рассмотреть целесообразность этого метода
        private PaEntry ElementUnchecked(long index)
        {
            PType t = ((PTypeSequence)tp).ElementType;

            if (t.HasNoTail)
            {
                return(new PaEntry(t, this.offset + 8 + index * t.HeadSize, cell));
            }
            long pos = this.offset + 8;

            for (long ii = 0; ii < index; ii++)
            {
                pos = Skip(t, pos);
            }
            return(new PaEntry(t, pos, cell));
        }
Example #43
0
        /// <summary>Overriden to setup PathELs.</summary>
        protected override EdgeListener CreateEdgeListener(int id)
        {
            NodeMapping snm = _shared_overlay.TakenIDs[id];

            if (snm.PathEM == null)
            {
                throw new Exception("Pathing should be enabled");
            }
            NodeMapping pnm = TakenIDs[id];

            pnm.PathEM = snm.PathEM;
            PType path_p = PType.Protocol.Pathing;

            pnm.Node.DemuxHandler.GetTypeSource(path_p).Subscribe(pnm.PathEM, path_p);
            return(snm.PathEM.CreatePath());
        }
Example #44
0
        /// <summary>
        /// Default constructor of a canoe
        /// </summary>
        /// <param name="serialNumber">serial number of a canoe</param>
        /// <param name="modelName">model name of a canoe</param>
        /// <param name="capacity">max passengers that can fit in a canoe</param>
        /// <param name="wholesalePrice">price we pay manufacturer for a canoe</param>
        /// <param name="retailPrice">price we charge retail stores for a canoe</param>
        /// <param name="length">length of a canoe</param>
        /// <param name="weight">weight of a canoe</param>
        /// <param name="canoebrand">brand of canoe</param>
        /// <param name="canoetype">type of a canoe</param>
        /// <param name="paddleType">paddle type need for canoe</param>
        public Canoe(string serialNumber, string modelName, int capacity, decimal wholesalePrice, decimal retailPrice, int length, int weight, CBrand canoebrand, CType canoetype, PType paddleType)
        {
            // WaterCraft
            this.SerialNumber = DefaultSN;
            this.ModelName = DefaultModelName;
            this.PassengerCapacity = DefaultPassengers;
            this.WholeSalePrice = DefaultWholeSalePrice;
            this.RetailPrice = DefaultRetailPrice;
            this.Length = DefaultLength;
            this.Weight = DefaultWeight;

            // Specific to Canoe
            this.CanoeBrand = DefaultCanoeBrand;
            this.CanoeType = DefaultCanoeType;
            this.PaddleType = DefaultPaddleType;
        }
Example #45
0
        public override void TranslateDictionarySet(StringBuilder sb, Expression dictionary, Expression key, Expression value)
        {
            PType dictType = dictionary.ResolvedType;

            sb.Append("Dictionary_set_");
            sb.Append(this.GetDictionaryKeyType(dictType.Generics[0]));
            sb.Append("_to_");
            sb.Append(this.GetDictionaryValueType(dictType.Generics[1]));
            sb.Append('(');
            this.TranslateExpression(sb, dictionary);
            sb.Append(", ");
            this.TranslateExpression(sb, key);
            sb.Append(", ");
            this.TranslateExpression(sb, value);
            sb.Append(")");
        }
Example #46
0
        public TableSignatures(PType tp_rec)
        {
            // table_ind, part_ind, node_ind, streams: [integer] (? набор номеров стримов для данной части)
            PType tp_sections = new PTypeSequence(new PTypeRecord(
                                                      new NamedType("table_ind", new PType(PTypeEnumeration.integer)),
                                                      new NamedType("section_ind", new PType(PTypeEnumeration.integer)),
                                                      new NamedType("node_ind", new PType(PTypeEnumeration.integer))));

            tp_record  = tp_rec;
            signatures = new Tuple <PType, PType>[] {
                new Tuple <PType, PType>(new PType(PTypeEnumeration.none), new PType(PTypeEnumeration.none)), // пустая команда для тестирования
                new Tuple <PType, PType>(new PType(PTypeEnumeration.integer),
                                         new PTypeRecord(
                                             new NamedType("id", new PType(PTypeEnumeration.integer)),
                                             new NamedType("nm", new PType(PTypeEnumeration.sstring)),
                                             new NamedType("ag", new PType(PTypeEnumeration.integer)))),         // sendinttest - имитация Get(k)
                new Tuple <PType, PType>(new PType(PTypeEnumeration.none), new PType(PTypeEnumeration.none)),    // Clear()
                new Tuple <PType, PType>(new PType(PTypeEnumeration.integer), new PType(PTypeEnumeration.none)), // Init(nodenum)
                new Tuple <PType, PType>(new PTypeRecord(
                                             new NamedType("pair", tp_record),
                                             new NamedType("dynindex", new PType(PTypeEnumeration.boolean))),
                                         new PType(PTypeEnumeration.none)), // AppendOnlyRecord(tab, record, bool dynindex)
                new Tuple <PType, PType>(new PTypeRecord(
                                             new NamedType("indx_nom", new PType(PTypeEnumeration.integer)),
                                             new NamedType("ext_key", new PType(PTypeEnumeration.integer)),
                                             new NamedType("pri_key", new PType(PTypeEnumeration.integer)),
                                             new NamedType("dynindex", new PType(PTypeEnumeration.boolean))),
                                         new PType(PTypeEnumeration.none)),                                   // AppendOnlyExtKey(int tab, int indx_nom, int ext_key, int pri_key, bool dynindex)
                new Tuple <PType, PType>(new PType(PTypeEnumeration.none), new PType(PTypeEnumeration.none)), // Flush()
                new Tuple <PType, PType>(new PType(PTypeEnumeration.none), new PType(PTypeEnumeration.none)), // CalculateStaticIndex()
                new Tuple <PType, PType>(new PType(PTypeEnumeration.none), new PType(PTypeEnumeration.none)), // Activate()
                new Tuple <PType, PType>(new PTypeRecord(
                                             //new NamedType("tab", new PType(PTypeEnumeration.integer)),
                                             new NamedType("key", new PType(PTypeEnumeration.integer))),
                                         tp_record), // GetByKey(tab, key) -> tp_record
                new Tuple <PType, PType>(new PTypeRecord(
                                             //new NamedType("tab", new PType(PTypeEnumeration.integer)),
                                             new NamedType("exindnom", new PType(PTypeEnumeration.integer)),
                                             new NamedType("exkey", new PType(PTypeEnumeration.integer))),
                                         new PTypeSequence(new PType(PTypeEnumeration.integer))),             // GetAllPrimaryByExternal(tab, exindnom, exkey) -> object[] { prikey,... }
                new Tuple <PType, PType>(new PType(PTypeEnumeration.none), new PType(PTypeEnumeration.none)), // CreateDatabase()
                new Tuple <PType, PType>(ConfigObject.tp, new PType(PTypeEnumeration.none)),                  // SaveConfiguration(configuration)
                new Tuple <PType, PType>(new PType(PTypeEnumeration.none), new PType(PTypeEnumeration.none)), // LoadConfiguration()
                new Tuple <PType, PType>(new PType(PTypeEnumeration.none), new PType(PTypeEnumeration.none)), // ActivateDatabase()
                new Tuple <PType, PType>(ConfigObject.tp, new PType(PTypeEnumeration.none)),                  // SetConfiguration(conf)
            }.ToArray();
        }
Example #47
0
        public static string TranslateJavaType(PType type)
        {
            switch (type.RootValue)
            {
            case "void": return("void");

            case "byte": return("byte");

            case "int": return("int");

            case "char": return("char");

            case "double": return("double");

            case "bool": return("boolean");

            case "object": return("Object");

            case "string": return("String");

            case "Array":
                string innerType = TranslateJavaType(type.Generics[0]);
                return(innerType + "[]");

            case "List":
                if (type.Generics[0].RootValue == "Value")
                {
                    return("FastList");
                }
                return("ArrayList<" + TranslateJavaNestedType(type.Generics[0]) + ">");

            case "Dictionary":
                return("HashMap<" + TranslateJavaNestedType(type.Generics[0]) + ", " + TranslateJavaNestedType(type.Generics[1]) + ">");

            case "ClassValue":
                // java.lang.ClassValue collision
                return("org.crayonlang.interpreter.structs.ClassValue");

            default:
                char firstChar = type.RootValue[0];
                if (firstChar >= 'A' && firstChar <= 'Z')
                {
                    return(type.RootValue);
                }
                throw new NotImplementedException();
            }
        }
Example #48
0
        public override void TranslateArrayLength(StringBuilder sb, Expression array)
        {
            PType itemType = array.ResolvedType.Generics[0];

            if (itemType.RootValue == "int")
            {
                sb.Append('(');
                this.TranslateExpression(sb, array);
                sb.Append(")[-1]");
            }
            else
            {
                sb.Append("((int*)(");
                this.TranslateExpression(sb, array);
                sb.Append("))[-1]");
            }
        }
Example #49
0
        private string GetDictionaryValueType(PType type)
        {
            switch (type.RootValue)
            {
            case "bool":
            case "int":
                return("int");

            case "string":
            case "double":
            case "char":
                return(type.RootValue);

            default:
                return("ptr");
            }
        }
Example #50
0
        private async Task <bool> GetPatternFor(PType type)
        {
            var folder =
                MainApp.Current.Core.DirectoryManager.GetFor <MainApp.Dirs>(Dirs.WorkDir)[MainApp.Dirs.Subject_Parser];
            //MainApp.Current.Core.DirectoryManager[MainApp.Dirs.Subject_Parser];
            var fmt = "ddMMyy";

            string[] files;
            while (true)
            {
                files = Directory.EnumerateFiles(folder).ToArray();
                if (files.Length != 0)
                {
                    break;
                }
                Console.WriteLine("Awaiting patterns");
                await Task.Delay(5000);
            }

            var lastDate = new DateTime();

            foreach (var file in files)
            {
                var f = new FileInfo(file);
                if (f.Name.Contains(type.ToString().ToLower()))
                {
                    var pts = f.Name.Split('_');
                    if (DateTime.TryParseExact(pts[1], fmt, null, DateTimeStyles.None, out var date) &&
                        lastDate < date)
                    {
                        lastDate = date;
                    }
                }
            }

            var may = Path.Combine(folder,
                                   $"pattern_{lastDate.ToString(fmt)}{'_'}{type.ToString().ToLower()}.txt");

            if (File.Exists(may))
            {
                patern.Add(type, File.ReadAllText(may));
                return(true);
            }

            return(false);
        }
Example #51
0
 public void SecureRingTest() {
   Parameters p = new Parameters("Test", "Test");
   string[] args = "-b=.2 -c --secure_edges -s=25".Split(' ');
   Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage);
   Simulator sim = new Simulator(p);
   _sim = sim;
   Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring");
   var nm0 = sim.TakenIDs.Values[0];
   int idx = 1;
   var nm1 = sim.TakenIDs.Values[idx];
   while(Simulator.AreConnected(nm0.Node, nm1.Node) && idx < sim.TakenIDs.Count) {
     nm1 = sim.TakenIDs.Values[++idx];
   }
   var ptype = new PType("chtest");
   var ch0 = new SecureConnectionHandler(ptype, (StructuredNode) nm0.Node, nm0.Sso);
   var ch1 = new SecureConnectionHandler(ptype, (StructuredNode) nm1.Node, nm1.Sso);
   ConnectionHandlerTest(nm0.Node, nm1.Node, ch0, ch1);
 }
Example #52
0
        public NewDialog(Project currentProject)
        {
            InitializeComponent();

            this.currentfolder=Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Moo Workspace";
            if (currentProject != null)
            {
                this.currentfolder = currentProject.Folder;
            }

            //initialise
            this.newoption = "PROJECT";
            this.projecttype = PType.Csharp;
            this.TypeCbx.Items.AddRange(new string[] { "C SHARP", "ILASM", "HYDRO", "V BASIC" });
            this.NameTbx.Text="";
            this.FolderTbx.Text = this.currentfolder;
            this.TypeCbx.SelectedIndex = 0;
        }
Example #53
0
 /// <summary>First half builds the ring, second half tests the connection handler...</summary>
 public void RingTest() {
   Parameters p = new Parameters("Test", "Test");
   string[] args = "-b=.2 -c -s=50".Split(' ');
   Assert.AreNotEqual(-1, p.Parse(args), "Unable to parse" + p.ErrorMessage);
   Simulator sim = new Simulator(p);
   _sim = sim;
   Assert.IsTrue(sim.Complete(true), "Simulation failed to complete the ring");
   SimpleTimer.RunSteps(fifteen_mins);
   Node node0 = sim.TakenIDs.Values[0].Node;
   int idx = 1;
   Node node1 = sim.TakenIDs.Values[idx].Node;
   while(Simulator.AreConnected(node0, node1) && idx < sim.TakenIDs.Count) {
     node1 = sim.TakenIDs.Values[++idx].Node;
   }
   var ptype = new PType("chtest");
   var ch0 = new ConnectionHandler(ptype, (StructuredNode) node0);
   var ch1 = new ConnectionHandler(ptype, (StructuredNode) node1);
   ConnectionHandlerTest(node0, node1, ch0, ch1);
 }
Example #54
0
        public string ImageUpload(PType p, HttpPostedFileBase file)
        {

            new FileUpload().SaveFile(file);
            return "";

            if (file == null) return new { success = false, msg = "请选择图片" }.GetJson();
            string ext = file.FileName.Substring(file.FileName.LastIndexOf('.')+1, file.FileName.Length - file.FileName.LastIndexOf('.')-1);
            //BMP、JPG、JPEG、PNG、GIF
            string[] imageExt = { "BPM", "JPG", "JPEG", "PNG", "GIF","ICO" };
            if (!imageExt.Contains(ext.ToUpper())) return new { success = false, msg = "只能上传图片文件" }.GetJson();

            byte[] buffer = null;
            buffer = new byte[file.ContentLength];
            file.InputStream.Read(buffer, 0, file.ContentLength);

            string[] ret = new FileUpload().PictureSave(p, "", buffer);
            if(ret==null) return new {success=false,msg="图片上传失败"}.GetJson();
            return new { success = true,imageId=ret[0] }.GetJson();
        }
        public MethodDescription(AMethodDecl method)
        {
            Parser parser = new Parser(method);

            Start = parser.Start;
            End = parser.End;
            ReturnType = parser.ReturnType;
            Name = parser.Name;
            Formals = parser.Formals;
            Locals = parser.Locals;
            if (method.Parent() != null)
                method.Parent().RemoveChild(method);
            IsDelegate = method.GetDelegate() != null;
            //if (!IsDelegate)
                Decl = method;
            IsStatic = method.GetStatic() != null;
            Visibility = method.GetVisibilityModifier();
            realType = (PType)method.GetReturnType().Clone();
            Position = TextPoint.FromCompilerCoords(method.GetName());
        }
Example #56
0
    private void buildProjectile(PType type) {
        GameObject x;
        switch (type) {
            case PType.ARROW:
                x = Instantiate(arrow, transform.position, Quaternion.identity) as GameObject;
                break;
            case PType.FIREBALL:
                x = Instantiate(fireball, transform.position, Quaternion.identity) as GameObject;
                break;
            default:
                x = Instantiate(arrow, transform.position, Quaternion.identity) as GameObject;
                break;
        }

        x.transform.parent = transform;
        x.SetActive(false);
        Projectile p = x.GetComponent<Projectile>();
        p.initialize(this, type);

        poolLookup[type].Add(p);
    }
Example #57
0
 protected override bool InternalIsEqual(PType otherType)
 {
     return otherType is IntPType;
 }
Example #58
0
        protected override bool InternalConvertTo(
            StackContext sctx,
            PValue subject,
            PType target,
            bool useExplicit,
            out PValue result)
        {
            result = null;

            if (useExplicit)
            {
                if (target is ObjectPType)
                {
                    var clrType = ((ObjectPType) target).ClrType;
                    if (clrType == typeof (Byte))
                        result = CreateObject((Byte) (Int32) subject.Value);
                    else if (clrType == typeof (Char))
                        result = CreateObject(Convert.ToChar((Int32) subject.Value));
                    else if (clrType == typeof (SByte))
                        result = CreateObject((SByte) (Int32) subject.Value);
                    else if (clrType == typeof (Int16))
                        result = CreateObject((Int16) (Int32) subject.Value);
                    else if (clrType == typeof (UInt16))
                        result = CreateObject((UInt16) (Int32) subject.Value);
                }
            }

            // (implicit or explicit
            if (result == null)
            {
                if (target is StringPType)
                    result = String.CreatePValue(subject.Value.ToString());
                else if (target is RealPType)
                    result = Real.CreatePValue((int) subject.Value);
                else if (target is BoolPType)
                    result = Bool.CreatePValue(((int) subject.Value) != 0);
                else if (target is ObjectPType)
                {
                    var clrType = ((ObjectPType) target).ClrType;
                    if (clrType == typeof (Int32))
                        result = CreateObject((Int32) subject.Value);
                    else if (clrType == typeof (Double))
                        result = CreateObject((Double) (Int32) subject.Value);
                    else if (clrType == typeof (Single))
                        result = CreateObject((Single) (Int32) subject.Value);
                    else if (clrType == typeof (Decimal))
                        result = CreateObject((Decimal) (Int32) subject.Value);
                    else if (clrType == typeof (Int64))
                        result = CreateObject((Int64) (Int32) subject.Value);
                    else if (clrType == typeof (UInt32))
                        result = CreateObject((UInt32) (Int32) subject.Value);
                    else if (clrType == typeof (UInt64))
                        result = CreateObject((UInt64) (Int32) subject.Value);
                }
            }

            return result != null;
        }
Example #59
0
 /// <summary>
 ///     Adds a new mapping from a CLR <see cref = "Type" /> to a <see cref = "PType" />.
 /// </summary>
 /// <param name = "clrType">The CLR <see cref = "Type" />.</param>
 /// <param name = "type">The <see cref = "PType" /></param>
 /// <exception cref = "ArgumentNullException">Either <paramref name = "clrType" /> or <paramref name = "type" /> is null.</exception>
 public void Add(Type clrType, PType type)
 {
     if (clrType == null)
         throw new ArgumentNullException("clrType");
     if ((object) type == null)
         throw new ArgumentNullException("type");
     if (_outer._pTypeMap.ContainsKey(clrType))
         throw new InvalidOperationException(
             "A mapping for the CLR Type " + clrType.FullName +
                 " already exists");
     _outer._pTypeMap.Add(clrType, type);
 }
Example #60
0
        public H264Mb(CommonMbH264 eltMb)
            : base(eltMb)
        {
            m_Mode = eltMb.getMode();
            m_SliceType = eltMb.getSliceType();
            m_MbType = eltMb.getMbType();
            m_QP = eltMb.getQP();
            m_QPC = eltMb.getQPC();
            m_CBP = eltMb.getCBP();
            m_IsIntra16x16 = eltMb.isIntra16x16();
            m_IsInter8x8 = eltMb.isInter8x8();
            m_IsIntra = eltMb.isIntra();
            m_NumMbPart = 1;
            m_MbPartSize = new Size(16, 16);

            if (m_Mode == MbMode.INTRA_4X4)
            {
                m_Intra4x4PredModes = new Intra4x4PredMode[16];
                eltMb.getIntra4x4PredMode(m_Intra4x4PredModes);
            }
            else if (m_IsIntra16x16)
            {
                m_I16x16Type = (m_SliceType == SliceType.P_SLICE) ? (I16x16Type)(m_MbType - 5) : (I16x16Type)m_MbType;
            }
            else if (m_SliceType == SliceType.P_SLICE)
            {
                if (m_MbType < 5 || m_Mode == MbMode.MODE_SKIP)
                {
                    if (m_Mode == MbMode.MODE_SKIP)
                    {
                        m_NumMbPart = 1;
                        m_MbPartSize = new Size(16, 16);
                    }
                    else
                    {
                        m_PType = (PType)m_MbType;
                        if (m_MbType < PartNumP.Length)
                        {
                            m_NumMbPart = PartNumP[m_MbType];
                        }
                        if (m_MbType < PartSizeP.Length)
                        {
                            m_MbPartSize = new Size((int)PartSizeP[m_MbType][0], (int)PartSizeP[m_MbType][1]);
                        }
                    }
                }
                else if (m_MbType == 5)
                {
                    // I_4x4
                    Debug.Assert(false);
                    m_IsIntra = true;
                }
                else
                {
                    // I_16x16
                    m_I16x16Type = (I16x16Type)(m_MbType - 5);
                    m_IsIntra = true;
                    m_IsIntra16x16 = true;
                }
            }
            else if (m_SliceType == SliceType.B_SLICE)
            {
                m_BType = (BType)m_MbType;
                if (m_MbType < PartNumB.Length)
                {
                    m_NumMbPart = PartNumB[m_MbType];
                }
                if (m_MbType < PartSizeP.Length)
                {
                    m_MbPartSize = new Size((int)PartSizeB[m_MbType][0], (int)PartSizeB[m_MbType][1]);
                }
            }

            if (m_IsInter8x8)
            {
                m_BlkModes = new BlkMode[4];
                eltMb.getBlkModes(m_BlkModes);
            }

            if (m_IsIntra)
            {
                m_IntraChromaPredMode = eltMb.getIntraChromaPredMode();
            }
            else
            {
                m_ref_idx_L0 = new Int32[4];
                m_POC0 = new Int32[4];
                m_mvd_l0 = eltMb.getMvdL0();
                m_mvL0 = eltMb.getMvL0();
                eltMb.getRefIdxL0(m_ref_idx_L0);
                eltMb.getPOC0(m_POC0);
                if (SliceType == SliceType.B_SLICE)
                {
                    m_ref_idx_L1 = new Int32[4];
                    m_POC1 = new Int32[4];
                    m_mvd_l1 = eltMb.getMvdL1();
                    m_mvL1 = eltMb.getMvL1();
                    eltMb.getRefIdxL1(m_ref_idx_L1);
                    eltMb.getPOC1(m_POC1);
                }
            }

            /*** SVC ***/
            m_IsInCropWindow = eltMb.isInCropWindow();
            m_IsResidualPredictionFlag = eltMb.isResidualPredictionFlag();
            m_IsBLSkippedFlag = eltMb.isBLSkippedFlag();
        }