Beispiel #1
0
                    public override void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services)
                    {
                        sw.Append("if(");
                        Jpf.Format(sw, formatterContext, services);
                        sw.AppendLine(")");
                        FormatBranch(sw, formatterContext, services, GetBodyInstructions());

                        foreach (var item in _aggregator.EnumerateElseBlocks())
                        {
                            item.Format(sw, formatterContext, services);
                        }
                    }
                public void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services)
                {
                    switch (_typeCode)
                    {
                    case TypeCode.SByte:
                        sw.Append("(SByte)");
                        break;

                    case TypeCode.Byte:
                        sw.Append("(Byte)");
                        break;

                    case TypeCode.Int16:
                        sw.Append("(Int16)");
                        break;

                    case TypeCode.UInt16:
                        sw.Append("(UInt16)");
                        break;
                    }

                    sw.Append(Value.ToString(CultureInfo.InvariantCulture));

                    if (_typeCode == TypeCode.UInt32)
                    {
                        sw.Append("u");
                    }
                }
Beispiel #3
0
        public static void FormatGlobalGet <T>(GlobalVariableId <T> globalVariable, Int32[] knownVariables, ScriptWriter sw, IScriptFormatterContext formatterContext, IServices executionContext) where T : unmanaged
        {
            if (knownVariables == null || Array.BinarySearch(knownVariables, globalVariable.VariableId) < 0)
            {
                sw.Append("(");
                sw.Append(GlobalVariableId <T> .TypeName);
                sw.Append(")");
                sw.Append("G");
            }
            else
            {
                sw.Append("G");
                sw.Append(GlobalVariableId <T> .TypeName);
            }

            sw.Append("[");
            sw.Append(globalVariable.VariableId.ToString(CultureInfo.InvariantCulture));
            sw.Append("]");
        }
Beispiel #4
0
        public static void FormatMonologue(ScriptWriter sw, String message)
        {
            if (!sw.HasWhiteLine)
            {
                sw.AppendLine();
            }

            foreach (String str in SplitMonologue(message))
            {
                if (String.IsNullOrEmpty(str))
                {
                    continue;
                }

                sw.Append("// ");
                sw.AppendLine(str);
            }
        }
Beispiel #5
0
            public MethodFormatter Argument <T>(String argumentName, IJsmExpression argumentExpression)
            {
                ScriptWriter sw = Formatter.Sw;

                if (_hasArguments)
                {
                    sw.Append(", ");
                }

                if (argumentName != null)
                {
                    sw.Append(argumentName);
                    sw.Append(": ");
                }

                sw.Append("(");
                sw.Append(typeof(T).Name);
                sw.Append(")");

                argumentExpression.Format(sw, Formatter.FormatterContext, Formatter.ExecutionContext);

                _hasArguments = true;
                return(this);
            }
Beispiel #6
0
 public void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services)
 {
     sw.Append("!");
     _value.Format(sw, formatterContext, services);
 }
 public void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services)
 {
     sw.Append(Value.ToString(CultureInfo.InvariantCulture));
 }
                public void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services)
                {
                    String name = formatterContext.GetObjectNameByIndex(_fieldObjectId.Value);

                    sw.Append($"typeof({name})");
                }
Beispiel #9
0
        public static void FormatAnswers(ScriptWriter sw, String message, IJsmExpression top, IJsmExpression bottom, IJsmExpression begin, IJsmExpression cancel)
        {
            if (!(top is IConstExpression t) || !(bottom is IConstExpression b))
            {
                FormatMonologue(sw, message);
                return;
            }

            if (!sw.HasWhiteLine)
            {
                sw.AppendLine();
            }

            // Question
            //☞ Answer 1
            //   Answer 2
            //   Answer 3
            //☜ Answer 4

            Int32 to = t.Int32();
            Int32 bo = b.Int32();
            Int32 be = -1;
            Int32 ca = -1;

            if (begin is IConstExpression beg)
            {
                be = beg.Int32();
            }

            if (cancel is IConstExpression can)
            {
                ca = can.Int32();
            }

            String[] lines = SplitMonologue(message);

            for (Int32 i = 0; i < lines.Length; i++)
            {
                sw.Append("//");
                if (i >= to && i <= bo)
                {
                    if (i == be)
                    {
                        sw.Append("☞ ");
                    }
                    else if (i == ca)
                    {
                        sw.Append("☜ ");
                    }
                    else
                    {
                        sw.Append("   ");
                    }
                }
                else
                {
                    sw.Append(" ");
                }

                sw.AppendLine(lines[i]);
            }
        }
 public void Format(ScriptWriter sw, IScriptFormatterContext formatterContext, IServices services)
 {
     sw.Append($"R{_index.ResultId}");
 }