Esempio n. 1
0
        internal ElaValue GetField(ElaValue index, ExecutionContext ctx)
        {
            if (vm != null)
            {
                if (index.TypeId != ElaMachine.STR)
                {
                    ctx.InvalidType(TCF.GetShortForm(ElaTypeCode.String), index);
                    return(Default());
                }

                var      field = index.DirectGetString();
                var      frame = vm.Assembly.GetModule(Handle);
                ScopeVar sc;

                if (!frame.GlobalScope.Locals.TryGetValue(field, out sc))
                {
                    ctx.UnknownField(index.DirectGetString(), new ElaValue(this));
                    return(Default());
                }

                if ((sc.Flags & ElaVariableFlags.Private) == ElaVariableFlags.Private)
                {
                    ctx.Fail(new ElaError(ElaRuntimeError.PrivateVariable, field));
                    return(Default());
                }

                return(vm.modules[Handle][sc.Address]);
            }

            ctx.Fail(ElaRuntimeError.Unknown, "VM is non present");
            return(Default());
        }
Esempio n. 2
0
        internal bool HasField(ElaValue key, ExecutionContext ctx)
        {
            var idx = key.I4;

            if (key.TypeId != ElaMachine.STR)
            {
                ctx.InvalidType(TCF.GetShortForm(ElaTypeCode.String), key);
                return(false);
            }

            return(GetOrdinal(key.DirectGetString()) != -1);
        }
Esempio n. 3
0
        internal bool HasField(ElaValue index, ExecutionContext ctx)
        {
            if (vm != null)
            {
                if (index.TypeId != ElaMachine.STR)
                {
                    ctx.InvalidType(TCF.GetShortForm(ElaTypeCode.String), index);
                    return(false);
                }

                var frame = vm.Assembly.GetModule(Handle);
                return(frame.GlobalScope.Locals.ContainsKey(index.DirectGetString()));
            }

            ctx.Fail(ElaRuntimeError.Unknown, "VM is non present");
            return(false);
        }
Esempio n. 4
0
        internal ElaValue GetField(ElaValue key, ExecutionContext ctx)
        {
            if (key.TypeId != ElaMachine.STR)
            {
                ctx.InvalidType(TCF.GetShortForm(ElaTypeCode.String), key);
                return(Default());
            }

            var idx = GetOrdinal(key.DirectGetString());

            if (idx == -1)
            {
                ctx.UnknownField(key.DirectGetString(), new ElaValue(this));
                return(Default());
            }

            return(values[idx]);
        }
Esempio n. 5
0
 private static Exception InvalidCast(ElaValue val, System.Type target)
 {
     return(new InvalidCastException(Strings.GetMessage("InvalidCast", TCF.GetShortForm(val.TypeCode),
                                                        target.Name)));
 }
Esempio n. 6
0
 private static Exception InvalidCast(ElaValue val, ElaTypeCode type)
 {
     return(new ElaRuntimeException(ElaRuntimeError.InvalidType, TCF.GetShortForm(type), val.GetTypeName()));
 }
Esempio n. 7
0
 public TypeData(ElaTypeCode typeCode) : this((Int32)typeCode, TCF.GetShortForm(typeCode))
 {
 }
Esempio n. 8
0
 protected internal virtual string GetTypeName()
 {
     return(TCF.GetShortForm((ElaTypeCode)TypeId));
 }
Esempio n. 9
0
 public static TreeNode Literal(this TreeNode par, ElaExpression exp, ElaTypeCode typeCode, object data)
 {
     return(Element(par, exp, TCF.GetShortForm(typeCode), data, "Literal", "{1} ({0})"));
 }