Ejemplo n.º 1
0
        public virtual IP5ScalarBody Assign(Runtime runtime, IP5ScalarBody other)
        {
            var osn = other as P5Reference;

            if (osn == null)
                return other.CloneBody(runtime);

            referred = osn.referred;

            return this;
        }
Ejemplo n.º 2
0
        public virtual IP5ScalarBody Assign(Runtime runtime, IP5ScalarBody other)
        {
            var osb = other as P5StringNumber;

            if (osb == null)
                return other.CloneBody(runtime);

            flags = osb.flags;
            pos = -1;
            pos_set = false;
            stringValue = osb.stringValue;
            integerValue = osb.integerValue;
            floatValue = osb.floatValue;

            return this;
        }
Ejemplo n.º 3
0
 public virtual void Undef(Runtime runtime)
 {
     if (!(body is P5Undef))
         body = P5Undef.Undef;
 }
Ejemplo n.º 4
0
        public void SetString(Runtime runtime, string value)
        {
            var str_num = body as P5StringNumber;

            if (str_num != null)
                str_num.SetString(runtime, value);
            else
                body = new P5StringNumber(runtime, value);
        }
Ejemplo n.º 5
0
        public void SetHandle(Runtime runtime, P5Handle handle)
        {
            var reference = body as P5Reference;

            if (reference != null)
            {
                reference.Referred = handle;
                return;
            }

            if (IsDefined(runtime))
                throw new System.NotImplementedException("No SetHandle for defined scalars");

            body = new P5Reference(runtime, handle);
        }
Ejemplo n.º 6
0
        public void SetFloat(Runtime runtime, double value)
        {
            var str_num = body as P5StringNumber;

            if (str_num != null)
                str_num.SetFloat(runtime, value);
            else
                body = new P5StringNumber(runtime, value);
        }
Ejemplo n.º 7
0
 public P5Scalar(IP5ScalarBody b)
 {
     body = b;
 }
Ejemplo n.º 8
0
        public virtual P5Scalar VivifyScalar(Runtime runtime)
        {
            var undef = body as P5Undef;

            if (undef != null)
                body = new P5Reference(runtime, new P5Scalar(runtime));

            return body.DereferenceScalar(runtime);
        }
Ejemplo n.º 9
0
        public virtual P5Scalar Assign(Runtime runtime, IP5Any other)
        {
            body = body.Assign(runtime, other.AsScalar(runtime).body);

            return this;
        }
Ejemplo n.º 10
0
 public virtual IP5ScalarBody Assign(Runtime runtime, IP5ScalarBody other)
 {
     return other.CloneBody(runtime);
 }
Ejemplo n.º 11
0
        public static P5Scalar SymbolicReferenceScalar(Runtime runtime, IP5ScalarBody any, bool create)
        {
            string name = any.AsString(runtime);
            var glob = SymbolicReference(runtime, name, create);

            if (glob == null)
                return null;
            if (glob.Scalar != null || !create)
                return glob.Scalar;

            return glob.Scalar = new P5Scalar(runtime);
        }
Ejemplo n.º 12
0
        public static P5Hash SymbolicReferenceHash(Runtime runtime, IP5ScalarBody any, bool create)
        {
            string name = any.AsString(runtime);

            if (name.EndsWith("::"))
            {
                var pack = runtime.SymbolTable.GetPackage(runtime, name.Substring(0, name.Length - 2), create);

                return pack;
            }

            var glob = SymbolicReference(runtime, name, create);

            if (glob == null)
                return null;
            if (glob.Hash != null || !create)
                return glob.Hash;

            return glob.Hash = new P5Hash(runtime);
        }
Ejemplo n.º 13
0
        public static P5Handle SymbolicReferenceHandle(Runtime runtime, IP5ScalarBody any, bool create)
        {
            string name = any.AsString(runtime);
            var glob = SymbolicReference(runtime, name, create);

            if (glob == null)
                return null;

            return glob.Handle;
        }
Ejemplo n.º 14
0
 public static P5Typeglob SymbolicReferenceGlob(Runtime runtime, IP5ScalarBody any, bool create)
 {
     string name = any.AsString(runtime);
     return SymbolicReference(runtime, name, create);
 }
Ejemplo n.º 15
0
        public static P5Code SymbolicReferenceCode(Runtime runtime, IP5ScalarBody any, bool create)
        {
            string name = any.AsString(runtime);
            var glob = SymbolicReference(runtime, name, create);

            if (glob == null)
                return null;
            if (glob.Code != null || !create)
                return glob.Code;

            return glob.Code = new P5Code(name, null);
        }
Ejemplo n.º 16
0
        public virtual IP5Array VivifyArray(Runtime runtime)
        {
            var undef = body as P5Undef;

            if (undef != null)
                body = new P5Reference(runtime, new P5Array(runtime));

            return body.DereferenceArray(runtime);
        }
Ejemplo n.º 17
0
        public virtual P5Hash VivifyHash(Runtime runtime)
        {
            var undef = body as P5Undef;

            if (undef != null)
                body = new P5Reference(runtime, new P5Hash(runtime));

            return body.DereferenceHash(runtime);
        }
Ejemplo n.º 18
0
        public virtual IP5Any AssignIterator(Runtime runtime, IEnumerator<IP5Any> iter)
        {
            if (iter.MoveNext())
                Assign(runtime, iter.Current);
            else
                body = P5Undef.Undef;

            return this;
        }
Ejemplo n.º 19
0
        private P5StringNumber ForceString(Runtime runtime)
        {
            P5StringNumber sn = body as P5StringNumber;
            if (sn == null)
                body = sn = new P5StringNumber(runtime, body.AsString(runtime));
            else if (sn.stringValue == null)
            {
                sn.stringValue = sn.AsString(runtime);
                sn.flags = P5StringNumber.HasString;
            }

            return sn;
        }
Ejemplo n.º 20
0
        public P5Scalar ConcatAssign(Runtime runtime, IP5Any other)
        {
            P5StringNumber sn = body as P5StringNumber;
            if (sn == null)
                body = sn = new P5StringNumber(runtime, body.AsString(runtime));
            else
                sn.flags = P5StringNumber.HasString;

            sn.stringValue = sn.stringValue + other.AsScalar(runtime).AsString(runtime);
            sn.pos = -1;

            return this;
        }
Ejemplo n.º 21
0
        public virtual IP5ScalarBody Assign(Runtime runtime, IP5ScalarBody other)
        {
            var osb = other as P5TypeglobBody;

            if (osb == null)
                return other.CloneBody(runtime);

            scalar = osb.scalar;
            array = osb.array;
            hash = osb.hash;
            handle = osb.handle;
            code = osb.code;

            return this;
        }
Ejemplo n.º 22
0
        public virtual P5Scalar PreIncrement(Runtime runtime)
        {
            var sb = body as P5StringNumber;

            if (sb != null)
                sb.Increment(runtime);
            else
                body = new P5StringNumber(runtime, body.AsInteger(runtime) + 1);

            return this;
        }