Exemplo n.º 1
0
        public static ILanguageExpression Translate(GMacExpressionBasicGenerator basicExprGen, ParseTreeNode node)
        {
            var context = basicExprGen.Context;

            context.PushState(node);

            var translator = new GMacExpressionAtomicSymbolicGenerator();//new GMacExpressionAtomicSymbolicGenerator(basicExprGen);

            translator.SetContext(basicExprGen);
            translator.Translate();

            context.PopState();

            var result = translator._generatedExpression;

            //MasterPool.Release(translator);

            return(result);
        }
Exemplo n.º 2
0
        //private ILanguageExpression translate_Expression_Cast(ParseTreeNode node)
        //{
        //    var langType = GMacValueAccessGenerator.Translate_Direct_LanguageType(this.Context, node.ChildNodes[0]);

        //    var expr = GMacExpressionGenerator.Translate(this.BasicExpressionGenerator, node.ChildNodes[0]);

        //    return this.BasicExpressionGenerator.Generate_TypeCast(langType, expr);
        //}

        protected override void Translate()
        {
            var subNode = RootParseNode.ChildNodes[0];

            switch (subNode.Term.Name)
            {
            case GMacParseNodeNames.ConstantNumber:
                _generatedExpression = translate_Constant_Number(subNode);
                break;

            case GMacParseNodeNames.ExpressionScoped:
                _generatedExpression = translate_Expression_Scoped(subNode);
                break;

            case GMacParseNodeNames.QualifiedItem:
                _generatedExpression = GMacValueAccessGenerator.Translate(Context, subNode.ChildNodes[0], false);
                break;

            case GMacParseNodeNames.ExpressionBracketed:
                _generatedExpression = GMacExpressionGenerator.Translate(BasicExpressionGenerator, subNode.ChildNodes[0]);
                break;

            case GMacParseNodeNames.StringLiteral:
                _generatedExpression = GMacExpressionAtomicSymbolicGenerator.Translate(Context, subNode);
                break;

            case GMacParseNodeNames.ExpressionComposite:
                _generatedExpression = GMacExpressionCompositeGenerator.Translate(Context, subNode);
                break;

            case GMacParseNodeNames.ExpressionFunction:
                _generatedExpression = GMacExpressionAtomicFunctionGenerator.Translate(BasicExpressionGenerator, subNode);
                break;

            default:
                CompilationLog.RaiseGeneratorError <ILanguageExpression>("Expression not recognized", RootParseNode);
                break;
            }
        }