mirror of
https://github.com/Cekis/SWG-ScriptConverter.git
synced 2026-09-11 22:44:59 -04:00
Add code
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using ScriptConverter.Parser;
|
||||
|
||||
namespace ScriptConverter.Ast.Declarations
|
||||
{
|
||||
abstract class Declaration
|
||||
{
|
||||
public readonly ScriptToken Start;
|
||||
public readonly ScriptToken End;
|
||||
|
||||
protected Declaration(ScriptToken start, ScriptToken end = null)
|
||||
{
|
||||
if (start == null)
|
||||
throw new ArgumentNullException("start");
|
||||
|
||||
Start = start;
|
||||
End = end ?? start;
|
||||
}
|
||||
|
||||
public abstract TDecl Accept<TDoc, TDecl, TStmt, TExpr>(IAstVisitor<TDoc, TDecl, TStmt, TExpr> visitor);
|
||||
|
||||
public abstract void SetParent();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using ScriptConverter.Ast.Expressions;
|
||||
using ScriptConverter.Parser;
|
||||
|
||||
namespace ScriptConverter.Ast.Declarations
|
||||
{
|
||||
class FieldDeclaration : Declaration
|
||||
{
|
||||
public ScriptType Type { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public Expression Value { get; private set; }
|
||||
public bool IsConstant { get; private set; }
|
||||
public bool IsPublic { get; private set; }
|
||||
|
||||
public FieldDeclaration(ScriptToken start, ScriptToken end, ScriptType type, string name, Expression value, bool isConst, bool isPublic)
|
||||
: base(start, end)
|
||||
{
|
||||
Type = type;
|
||||
Name = name;
|
||||
Value = value;
|
||||
IsConstant = isConst;
|
||||
IsPublic = isPublic;
|
||||
}
|
||||
|
||||
public override TDecl Accept<TDoc, TDecl, TStmt, TExpr>(IAstVisitor<TDoc, TDecl, TStmt, TExpr> visitor)
|
||||
{
|
||||
return visitor.Visit(this);
|
||||
}
|
||||
|
||||
public override void SetParent()
|
||||
{
|
||||
Value.SetParent(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using ScriptConverter.Parser;
|
||||
|
||||
namespace ScriptConverter.Ast.Declarations
|
||||
{
|
||||
class IncludeDeclaration : Declaration
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
|
||||
public IncludeDeclaration(ScriptToken start, ScriptToken end, string name)
|
||||
: base(start, end)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public override TDecl Accept<TDoc, TDecl, TStmt, TExpr>(IAstVisitor<TDoc, TDecl, TStmt, TExpr> visitor)
|
||||
{
|
||||
return visitor.Visit(this);
|
||||
}
|
||||
|
||||
public override void SetParent()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using ScriptConverter.Parser;
|
||||
|
||||
namespace ScriptConverter.Ast.Declarations
|
||||
{
|
||||
class InheritsDeclaration : Declaration
|
||||
{
|
||||
public string Name { get; private set; }
|
||||
|
||||
public InheritsDeclaration(ScriptToken start, ScriptToken end, string name)
|
||||
: base(start, end)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
public override TDecl Accept<TDoc, TDecl, TStmt, TExpr>(IAstVisitor<TDoc, TDecl, TStmt, TExpr> visitor)
|
||||
{
|
||||
return visitor.Visit(this);
|
||||
}
|
||||
|
||||
public override void SetParent()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using ScriptConverter.Ast.Statements;
|
||||
using ScriptConverter.Parser;
|
||||
|
||||
namespace ScriptConverter.Ast.Declarations
|
||||
{
|
||||
class MethodDeclaration : Declaration
|
||||
{
|
||||
public class Parameter
|
||||
{
|
||||
public ScriptType Type { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
|
||||
public Parameter(ScriptType type, string name)
|
||||
{
|
||||
Type = type;
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
|
||||
public ScriptType ReturnType { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public ReadOnlyCollection<Parameter> Parameters { get; private set; }
|
||||
public BlockStatement Block { get; private set; }
|
||||
|
||||
public MethodDeclaration(ScriptToken start, ScriptToken end, ScriptType returnType, string name, List<Parameter> parameters, BlockStatement block)
|
||||
: base(start, end)
|
||||
{
|
||||
ReturnType = returnType;
|
||||
Name = name;
|
||||
Parameters = parameters.AsReadOnly();
|
||||
Block = block;
|
||||
}
|
||||
|
||||
public override TDecl Accept<TDoc, TDecl, TStmt, TExpr>(IAstVisitor<TDoc, TDecl, TStmt, TExpr> visitor)
|
||||
{
|
||||
return visitor.Visit(this);
|
||||
}
|
||||
|
||||
public override void SetParent()
|
||||
{
|
||||
Block.SetParent(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user