Example #1
0
 internal PrimitiveToken(PrimitiveTokenDataSet dataSet)
 {
     parent           = dataSet.Parent;
     codeType         = dataSet.DicValue.Type;
     codeExtraFlags   = dataSet.DicValue.Extra;
     dicValueName     = dataSet.DicValue.Name;
     oparatorPriority = dataSet.DicValue.OparatorPriority;
     tokenOffset      = dataSet.TokenOffset;
     type             = dataSet.Type;
     flag             = dataSet.Flag;
     value            = dataSet.Value;
     name             = dataSet.Name;
 }
        private PrimitiveToken createPrimitive(AxData data, HspDictionaryValue dicValue, int theTokenOffset, int type, int flag, int value, int extraValue)
        {
            PrimitiveTokenDataSet dataset = new PrimitiveTokenDataSet();

            dataset.Parent      = data;
            dataset.DicValue    = dicValue;
            dataset.TokenOffset = theTokenOffset;
            dataset.Type        = type;
            dataset.Flag        = flag;
            dataset.Value       = value;
            dataset.Name        = dicValue.Name;
            switch (dicValue.Type)
            {
            case HspCodeType.Label:
                return(new LabelPrimitive(dataset));

            case HspCodeType.Integer:
                return(new IntegerPrimitive(dataset));

            case HspCodeType.Double:
                return(new DoublePrimitive(dataset, data.ReadDoubleLiteral(value)));

            case HspCodeType.String:
                return(new StringPrimitive(dataset, data.ReadStringLiteral(value)));

            case HspCodeType.Symbol:
                return(new SymbolPrimitive(dataset));

            case HspCodeType.Param:
                return(new ParameterPrimitive(dataset));

            case HspCodeType.Variable:
                return(new GlobalVariablePrimitive(dataset));

            case HspCodeType.Operator:
                return(new OperatorPrimitive(dataset));

            case HspCodeType.IfStatement:
            case HspCodeType.ElseStatement:
                if (extraValue >= 0)
                {
                    return(new IfStatementPrimitive(dataset, extraValue));
                }
                else
                {
                    return(new HspFunctionPrimitive(dataset));
                }

            case HspCodeType.HspFunction:
                return(new HspFunctionPrimitive(dataset));

            case HspCodeType.OnStatement:
                return(new OnFunctionPrimitive(dataset));

            case HspCodeType.OnEventStatement:
                return(new OnEventFunctionPrimitive(dataset));

            case HspCodeType.McallStatement:
                return(new McallFunctionPrimitive(dataset));

            case HspCodeType.UserFunction:
                return(new UserFunctionPrimitive(dataset));

            case HspCodeType.DllFunction:
                return(new DllFunctionPrimitive(dataset));

            case HspCodeType.PlugInFunction:
                return(new PlugInFunctionPrimitive(dataset));

            case HspCodeType.ComFunction:
                return(new ComFunctionPrimitive(dataset));

            case HspCodeType.NONE:
            default:
                break;
            }
            return(new UnknownPrimitive(dataset));
        }