Exemplo n.º 1
0
        public ICQ_Value MakeValue(object value)
        {
            CQ_Value_ScriptValue svalue = new CQ_Value_ScriptValue();

            svalue.value_value = value as SInstance;
            svalue.value_type  = type;
            return(svalue);
        }
Exemplo n.º 2
0
        public CQ_Content.Value New(CQ_Content content, IList <CQ_Content.Value> _params)
        {
            if (contentMemberCalc == null)
            {
                contentMemberCalc = new CQ_Content(content.environment);
            }
            NewStatic(content.environment);
            CQ_Value_ScriptValue sv = new CQ_Value_ScriptValue();

            sv.value_type       = this;
            sv.value_value      = new SInstance();
            sv.value_value.type = this;
            foreach (KeyValuePair <string, Member> i in this.members)
            {
                if (i.Value.bStatic == false)
                {
                    if (i.Value.expr_defvalue == null)
                    {
                        sv.value_value.member[i.Key]       = new CQ_Content.Value();
                        sv.value_value.member[i.Key].type  = i.Value.type.type;
                        sv.value_value.member[i.Key].value = i.Value.type.DefValue;
                    }
                    else
                    {
                        var value = i.Value.expr_defvalue.ComputeValue(contentMemberCalc);
                        if (i.Value.type.type != value.type)
                        {
                            sv.value_value.member[i.Key]       = new CQ_Content.Value();
                            sv.value_value.member[i.Key].type  = i.Value.type.type;
                            sv.value_value.member[i.Key].value = content.environment.GetType(value.type).ConvertTo(content, value.value, i.Value.type.type);
                        }
                        else
                        {
                            sv.value_value.member[i.Key] = value;
                        }
                    }
                }
            }
            if (this.functions.ContainsKey(this.Name))//有同名函数就调用
            {
                MemberCall(content, sv.value_value, this.Name, _params);
            }
            return(CQ_Content.Value.FromICQ_Value(sv));
        }