Ejemplo n.º 1
0
        public override string GenerateCode()
        {
            var javaType = TypesTable.Instance.GetType(Type);

            if (javaType is EnumType)
            {
                BaseType enumType = (EnumType)javaType;
                return($"{javaType.ToJavaString()} {IdNode.GenerateCode()} = {enumType.ToJavaString()}.{Value.GenerateCode()};");
            }

            return($"{javaType.ToJavaString()} {IdNode.GenerateCode()} = {Value.GenerateCode()};");
        }
Ejemplo n.º 2
0
        public override string GenerateCode()
        {
            var javaType = Value.ValidateSemantic();

            if (javaType is EnumType)
            {
                var enumType = (EnumType)javaType;
                return($"{ValueIdNode.GenerateCode()} = {enumType.ToJavaString()}.{Value.GenerateCode()};");
            }
            else if (javaType is ArrayType)
            {
            }
            return($"{ValueIdNode.GenerateCode()} = {Value.GenerateCode()};");
        }
Ejemplo n.º 3
0
        public override string GenerateCode()
        {
            var counter = IdNode.GenerateCode();
            var forCode = $"for ({counter} = {CounterValue.GenerateCode()}; {counter} < {Condition.GenerateCode()}; {counter}++){{\n";

            foreach (var sentenceNode in Statements)
            {
                forCode += sentenceNode.GenerateCode() + "\n";
            }
            return(forCode + "}\n");
        }
Ejemplo n.º 4
0
        public override ExpressionCode GenerateCode()
        {
            var helper     = new GenerationHelper();
            var stringCode = "";

            stringCode += IdNode.GenerateCode().Code;
            if (AssignmentNode != null)
            {
                stringCode += AssignmentNode.GenerateCode().Code;
            }
            stringCode += PostId;

            return(new ExpressionCode {
                Code = stringCode, Type = IdNode.GenerateCode().Type
            });
        }
Ejemplo n.º 5
0
        public override string GenerateCode()
        {
            SymbolTable.AddSymbolTable(ForInSymbolTable);
            var collection = (ArrayType)TypesTable.Instance.GetType(IdNodeCollection.Value);
            //SymbolTable.Instance.DeclareVariable(IdNode.Value, collection.Type);

            var collectionBaseType = collection.ToJavaString();
            var forInCode          = $"for({collectionBaseType} {IdNode.GenerateCode()} : {IdNodeCollection.GenerateCode()}){{\n";

            foreach (var sentenceNode in Statements)
            {
                forInCode += sentenceNode.GenerateCode() + "\n";
            }
            SymbolTable.RemoveSymbolTable();

            return(forInCode + "}");
        }
Ejemplo n.º 6
0
        public override string GenerateCode()
        {
            var constType = Expression.ValidateSemantic().ToJavaString();

            return($"public final {constType} {IdNode.GenerateCode()} = {Expression.GenerateCode()};");
        }
        public override string GenerateCode()
        {
            var constType = TypesTable.Instance.GetType(Type).ToJavaString();

            return($"public final {constType} {IdNode.GenerateCode()} = {Expression.GenerateCode()};");
        }