Пример #1
0
 protected override bool Load(Dsl.ValueData valData)
 {
     m_VarId = valData.GetId();
     return(true);
 }
Пример #2
0
 internal static void writeBinary(MemoryStream stream, List<string> identifiers, ValueData data)
 {
     stream.WriteByte((byte)DslBinaryCode.BeginValue);
     if (null != data) {
         stream.WriteByte((byte)((int)DslBinaryCode.ValueTypeBegin + data.GetIdType()));
         identifiers.Add(data.GetId());
     }
     stream.WriteByte((byte)DslBinaryCode.EndValue);
 }
Пример #3
0
        public IExpression Load(Dsl.ISyntaxComponent comp)
        {
            Dsl.ValueData    valueData = comp as Dsl.ValueData;
            Dsl.FunctionData funcData  = null;
            if (null != valueData)
            {
                int idType = valueData.GetIdType();
                if (idType == Dsl.ValueData.ID_TOKEN)
                {
                    string id = valueData.GetId();
                    if (id == "true" || id == "false")
                    {
                        ConstGet constExp = new ConstGet();
                        constExp.Load(comp, this);
                        return(constExp);
                    }
                    else
                    {
                        NamedVarGet varExp = new NamedVarGet();
                        varExp.Load(comp, this);
                        return(varExp);
                    }
                }
                else
                {
                    ConstGet constExp = new ConstGet();
                    constExp.Load(comp, this);
                    return(constExp);
                }
            }
            else
            {
                funcData = comp as Dsl.FunctionData;
                if (null != funcData && funcData.HaveParam())
                {
                    var    callData = funcData;
                    string op       = callData.GetId();
                    if (op == "=")  //赋值
                    {
                        IExpression exp  = null;
                        string      name = callData.GetParamId(0);
                        exp = new NamedVarSet();
                        if (null != exp)
                        {
                            exp.Load(comp, this);
                        }
                        else
                        {
                            //error
                            Log("Interpreter error, {0} line {1}", callData.ToScriptString(false), callData.GetLine());
                        }
                        return(exp);
                    }
                }
            }
            IExpression ret   = null;
            string      expId = comp.GetId();

            if (null != funcData && !funcData.IsHighOrder && m_Funcs.ContainsKey(expId))
            {
                ret = new FuncCallExp();
            }
            else
            {
                IExpressionFactory factory;
                if (m_Apis.TryGetValue(expId, out factory))
                {
                    ret = factory.Create();
                }
            }
            if (null != ret)
            {
                if (!ret.Load(comp, this))
                {
                    //error
                    Log("Interpreter error, {0} line {1}", comp.ToScriptString(false), comp.GetLine());
                }
            }
            else
            {
                //error
                Log("Interpreter error, {0} line {1}", comp.ToScriptString(false), comp.GetLine());
            }
            return(ret);
        }