Example #1
0
 public override void Print(TextBuilder result, LabelTableToken labelTable, bool showStartOffsets)
 {
     PrintLabel(labelTable, result);
     result.Indent();
     PrintHead(result);
     result.Append("\n");
     result.Indent().Append("{\n");
     PrintChildren(result, labelTable, showStartOffsets);
     result.Indent().Append("}");
     //            result.Append("   // ").Append(_endOffset.ToString());
     result.NewLine();
 }
Example #2
0
        public override void Decompile(TextBuilder result)
        {
            result.Append("class ").Append(_self.ObjectName);
            if (_super != null)
            {
                result.Append(" extends ").Append(_super.ObjectName);
            }
            if (_outerInstance != null && _outerInstance.ObjectName != "Object")
            {
                result.NewLine().Append("    within ").Append(_outerInstance.ObjectName);
            }
            if (_hideCategories.Count > 0)
            {
                result.NewLine().Append("    hidecategories(").Append(string.Join(",", _hideCategories.ToArray())).Append(")");
            }
            if (_interfaces.Count > 0)
            {
                var intfNames = _interfaces.ConvertAll(e => e.ObjectName).ToArray();
                result.NewLine().Append("    implements(").Append(string.Join(",", intfNames)).Append(")");
            }
            if (_config != "None")
            {
                result.NewLine().Append("    config(").Append(_config).Append(")");
            }
            _flags.Except("Compiled", "Parsed", "Config", "Localized").Each(f => result.NewLine().Append("    ").Append(f.ToLower()));
            result.Append(";").NewLine().NewLine();
            DecompileChildren(result, false);

            var statementList = ReadBytecode();

            if (statementList.Count > 0)
            {
                DecompileReplicationBlock(result, statementList);
            }
            if (_defaults != null)
            {
                DecompileDefaultProperties(result);
            }
        }
Example #3
0
 public override void Decompile(TextBuilder result)
 {
     result.Indent().Append("struct ");
     if (Native) result.Append("native ");
     if (Transient) result.Append("transient ");
     result.Append(_self.ObjectName);
     if (_super != null)
     {
         result.Append(" extends ").Append(_super.ObjectName);
     }
     result.NewLine();
     result.Append("{").NewLine();
     result.PushIndent();
     DecompileChildren(result, true);
     result.PopIndent();
     result.Indent().Append("}").NewLine().NewLine();
 }
Example #4
0
 public override void Decompile(TextBuilder result)
 {
     result.Indent().Append("struct ");
     if (Native)
     {
         result.Append("native ");
     }
     if (Transient)
     {
         result.Append("transient ");
     }
     result.Append(_self.ObjectName);
     if (_super != null)
     {
         result.Append(" extends ").Append(_super.ObjectName);
     }
     result.NewLine();
     result.Append("{").NewLine();
     result.PushIndent();
     DecompileChildren(result, true);
     result.PopIndent();
     result.Indent().Append("}").NewLine().NewLine();
 }
Example #5
0
 public override void Print(TextBuilder result, LabelTableToken labelTable, bool showStartOffsets)
 {
     PrintLabel(labelTable, result);
     result.Indent();
     PrintHead(result);
     result.Append("\n");
     result.Indent().Append("{\n");
     PrintChildren(result, labelTable, showStartOffsets);
     result.Indent().Append("}");
     //            result.Append("   // ").Append(_endOffset.ToString());
     result.NewLine();
 }
Example #6
0
        public void Decompile(TextBuilder result, bool createControlStatements)
        {
            result.Indent();
            if (Native)
            {
                result.Append("native");
                if (_nativeIndex > 0)
                {
                    result.Append("(").Append(_nativeIndex).Append(")");
                }
                result.Append(" ");
            }

            _flags.Except("Native", "Event", "Delegate", "Defined", "Public", "HasDefaults", "HasOutParms").Each(f => result.Append(f.ToLower() + " "));

            if (HasFlag("Event"))
            {
                result.Append("event ");
            }
            else if (HasFlag("Delegate"))
            {
                result.Append("delegate ");
            }
            else
            {
                result.Append("function ");
            }
            string type = GetReturnType();

            if (type != null)
            {
                result.Append(type).Append(" ");
            }
            result.Append(_self.ObjectName).Append("(");
            int paramCount = 0;
            var locals     = new List <UnClassProperty>();

            var statements = ReadBytecode();

            foreach (UnExport export in _self.Children.Reverse())
            {
                object instance = export.ReadInstance();
                if (instance is UnClassProperty)
                {
                    var prop = (UnClassProperty)instance;
                    if (prop.Parm)
                    {
                        if (!prop.ReturnParm)
                        {
                            if (paramCount > 0)
                            {
                                result.Append(", ");
                            }

                            prop.Flags.Except("Parm").Each(f => result.Append(f.ToLower() + " "));
                            result.Append(prop.GetPropertyType()).Append(" ").Append(export.ObjectName);
                            if (prop.OptionalParm && statements.Count > 0)
                            {
                                if (statements[0].Token is NothingToken)
                                {
                                    statements.RemoveRange(0, 1);
                                }
                                else if (statements [0].Token is DefaultParamValueToken)
                                {
                                    result.Append(" = ").Append(statements[0].Token.ToString());
                                    statements.RemoveRange(0, 1);
                                }
                            }
                            paramCount++;
                        }
                    }
                    else
                    {
                        locals.Add(prop);
                    }
                }
            }
            result.Append(")");
            if (HasFlag("Defined"))
            {
                result.NewLine().Indent().Append("{").NewLine();
                result.PushIndent();
                foreach (var local in locals)
                {
                    result.Indent().Append("local ").Append(local.GetPropertyType()).Append(" ").Append(local.Name).Append(";").NewLine();
                }
                result.PopIndent();   // will be pushed again in DecompileBytecode()
                DecompileBytecode(statements, result, createControlStatements);
                result.Indent().Append("}").NewLine().NewLine();
            }
            else
            {
                result.Append(";").NewLine().NewLine();
            }
        }
Example #7
0
        public override void Decompile(TextBuilder result)
        {
            result.Append("class ").Append(_self.ObjectName);
            if (_super != null)
                result.Append(" extends ").Append(_super.ObjectName);
            if (_outerInstance != null && _outerInstance.ObjectName != "Object")
            {
                result.NewLine().Append("    within ").Append(_outerInstance.ObjectName);
            }
            if (_hideCategories.Count > 0)
            {
                result.NewLine().Append("    hidecategories(").Append(string.Join(",", _hideCategories.ToArray())).Append(")");
            }
            if (_interfaces.Count > 0)
            {
                var intfNames = _interfaces.ConvertAll(e => e.ObjectName).ToArray();
                result.NewLine().Append("    implements(").Append(string.Join(",", intfNames)).Append(")");
            }
            if (_config != "None")
            {
                result.NewLine().Append("    config(").Append(_config).Append(")");
            }
            _flags.Except("Compiled", "Parsed", "Config", "Localized").Each(f => result.NewLine().Append("    ").Append(f.ToLower()));
            result.Append(";").NewLine().NewLine();
            DecompileChildren(result, false);

            var statementList = ReadBytecode();
            if (statementList.Count > 0)
            {
                DecompileReplicationBlock(result, statementList);
            }
            if (_defaults != null)
            {
                DecompileDefaultProperties(result);
            }
        }
Example #8
0
        public void Decompile(TextBuilder result, bool createControlStatements)
        {
            result.Indent();
            if (Native)
            {
                result.Append("native");
                if (_nativeIndex > 0)
                    result.Append("(").Append(_nativeIndex).Append(")");
                result.Append(" ");
            }

            _flags.Except("Native", "Event", "Delegate", "Defined", "Public", "HasDefaults", "HasOutParms").Each(f => result.Append(f.ToLower() + " "));

            if (HasFlag("Event"))
                result.Append("event ");
            else if (HasFlag("Delegate"))
                result.Append("delegate ");
            else
                result.Append("function ");
            string type = GetReturnType();
            if (type != null)
            {
                result.Append(type).Append(" ");
            }
            result.Append(_self.ObjectName).Append("(");
            int paramCount = 0;
            var locals = new List<UnClassProperty>();

            var statements = ReadBytecode();
            foreach (UnExport export in _self.Children.Reverse())
            {
                object instance = export.ReadInstance();
                if (instance is UnClassProperty)
                {
                    var prop = (UnClassProperty)instance;
                    if (prop.Parm)
                    {
                        if (!prop.ReturnParm)
                        {
                            if (paramCount > 0)
                                result.Append(", ");

                            prop.Flags.Except("Parm").Each(f => result.Append(f.ToLower() + " "));
                            result.Append(prop.GetPropertyType()).Append(" ").Append(export.ObjectName);
                            if (prop.OptionalParm && statements.Count > 0)
                            {
                                if (statements[0].Token is NothingToken)
                                    statements.RemoveRange(0, 1);
                                else if (statements [0].Token is DefaultParamValueToken)
                                {
                                    result.Append(" = ").Append(statements[0].Token.ToString());
                                    statements.RemoveRange(0, 1);
                                }
                            }
                            paramCount++;
                        }
                    }
                    else
                    {
                        locals.Add(prop);
                    }
                }
            }
            result.Append(")");
            if (HasFlag("Defined"))
            {
                result.NewLine().Indent().Append("{").NewLine();
                result.PushIndent();
                foreach (var local in locals)
                {
                    result.Indent().Append("local ").Append(local.GetPropertyType()).Append(" ").Append(local.Name).Append(";").NewLine();
                }
                result.PopIndent();   // will be pushed again in DecompileBytecode()
                DecompileBytecode(statements, result, createControlStatements);
                result.Indent().Append("}").NewLine().NewLine();
            }
            else
            {
                result.Append(";").NewLine().NewLine();
            }
        }