コード例 #1
0
        public override void CaseAVariableDefinition(AVariableDefinition node)
        {
            // create the variable in the data segment
            DataSegmentElement elm = new DataSegmentElement(node.GetName().Text, TypeEnvironment.GetVxcTypeOf(node.GetTypeSpecifier().GetType()));

            mOutputFile.mDataSegment.Add(elm);

            // create initializer expression in code segment.
            PExpression pexp = node.GetInit();

            if (pexp != null)
            {
                long value = TypeEnvironment.GetValueOf(pexp);
                VariableInitializerExpression exp = new VariableInitializerExpression(value, elm.Type, elm.Identifier);
                mOutputFile.AddTemplate("init", exp);
            }

            base.CaseAVariableDefinition(node);
        }