Пример #1
0
 private AbstractSyntaxComponent simplifyStatement(CallData data)
 {
     if (!data.HaveParam())
     {
         //没有参数的调用退化为基本值数据
         if (data.IsHighOrder)
         {
             //这种情况应该不会出现
             return(data);
         }
         else
         {
             data.Name.CopyComments(data);
             return(data.Name);
         }
     }
     else if (data.GetId() == "-" && data.GetParamNum() == 1)
     {
         ISyntaxComponent val  = data.GetParam(0);
         ValueData        temp = val as ValueData;
         if (null != temp && temp.IsNumber())
         {
             ValueData ret = new ValueData("-" + temp.GetId(), ValueData.NUM_TOKEN);
             ret.CopyComments(temp);
             ret.CopyComments(data);
             return(ret);
         }
         else
         {
             simplifyCallData(data);
             return(data);
         }
     }
     else if (data.GetId() == "+" && data.GetParamNum() == 1)
     {
         ISyntaxComponent val  = data.GetParam(0);
         ValueData        temp = val as ValueData;
         if (null != temp && temp.IsNumber())
         {
             ValueData ret = new ValueData(temp.GetId(), ValueData.NUM_TOKEN);
             ret.CopyComments(temp);
             ret.CopyComments(data);
             return(ret);
         }
         else
         {
             simplifyCallData(data);
             return(data);
         }
     }
     else
     {
         //有参数不会退化,对各参数进行化简
         simplifyCallData(data);
         return(data);
     }
 }
Пример #2
0
 private AbstractSyntaxComponent simplifyStatement(FunctionData data)
 {
     //注意,为了省内存ValueData上不附带注释了,相关接口无实际效果!!!
     if (!data.HaveParamOrStatement())
     {
         //没有参数的调用退化为基本值数据
         if (data.IsHighOrder)
         {
             //这种情况应该不会出现
             return(data);
         }
         else
         {
             return(data.Name);
         }
     }
     else if (data.GetId() == "-" && data.GetParamNum() == 1)
     {
         ISyntaxComponent val  = data.GetParam(0);
         ValueData        temp = val as ValueData;
         if (null != temp && temp.IsNumber())
         {
             ValueData ret = new ValueData("-" + temp.GetId(), ValueData.NUM_TOKEN);
             return(ret);
         }
         else
         {
             return(data);
         }
     }
     else if (data.GetId() == "+" && data.GetParamNum() == 1)
     {
         ISyntaxComponent val  = data.GetParam(0);
         ValueData        temp = val as ValueData;
         if (null != temp && temp.IsNumber())
         {
             ValueData ret = new ValueData(temp.GetId(), ValueData.NUM_TOKEN);
             return(ret);
         }
         else
         {
             return(data);
         }
     }
     else
     {
         return(data);
     }
 }