port from perforce

This commit is contained in:
2026-04-18 22:31:51 +02:00
commit 8d0ab5b7cc
8409 changed files with 3972376 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
using System.Collections.Generic;
using System.Linq;
namespace Intromat.Model.Compiler
{
public class ScopeDefinition
{
public ScopeDefinition(string identifier)
{
Identifier = identifier;
}
public string Identifier { get; }
public List<IVariableDefinition> Variables { get; } = new();
}
public class CompilerContext
{
public Stack<ScopeDefinition> VariablesScopesStack { get; } = new();
public string FindFreeVariableName()
{
return "v" + VariablesScopesStack.SelectMany(s => s.Variables).Count();
}
public void AddVariableToCurrentScope(IVariableDefinition variable)
{
VariablesScopesStack.Peek().Variables.Add(variable);
}
public void EnterNewScope(string scopeIdentifier)
{
VariablesScopesStack.Push(new ScopeDefinition(scopeIdentifier));
}
public void LeaveScope()
{
VariablesScopesStack.Pop();
}
public bool IsInScope(IVariableDefinition variable)
{
if (variable == null) return false;
return VariablesScopesStack.Any(s => s.Variables.Contains(variable));
}
}
}

View File

@@ -0,0 +1,15 @@
using System;
namespace Intromat.Model.Compiler.Error
{
public class CompilerException : Exception
{
public CompilerException(string msg) : base(msg)
{
}
public CompilerException(string msg, Exception inner) : base(msg, inner)
{
}
}
}

View File

@@ -0,0 +1,13 @@
namespace Intromat.Model.Compiler.Error
{
public class VariableOutOfScopeException : CompilerException
{
public VariableOutOfScopeException(string variableName)
: base($"The variable '{variableName}' was referenced outside its scope.")
{
VariableName = variableName;
}
public string VariableName { get; }
}
}

View File

@@ -0,0 +1,10 @@
using System.Text;
namespace Intromat.Model.Compiler
{
public interface IStatement
{
void Compile(CompilerContext context, StringBuilder sb);
void CompileHeader(CompilerContext context, StringBuilder sb);
}
}

View File

@@ -0,0 +1,15 @@
using System.Text;
namespace Intromat.Model.Compiler
{
public interface IExpression
{
void Compile(CompilerContext context, StringBuilder sb);
}
public interface ITypedExpression<T> : IExpression
{
string? PreviewValue { get; }
T Evaluate();
}
}

View File

@@ -0,0 +1,15 @@
using SharpDX.Direct3D11;
namespace Intromat.Model.Compiler
{
public class MeshValue
{
public MeshValue()
{
}
public MeshValue(MeshValue other)
{
}
}
}

View File

@@ -0,0 +1,24 @@
using SharpDX.Direct3D11;
namespace Intromat.Model.Compiler
{
public class TextureValue
{
public TextureValue()
{
}
public TextureValue(TextureValue other)
{
Width = other.Width;
Height = other.Height;
ShaderResourceView = other.ShaderResourceView;
UnorderedAccessView = other.UnorderedAccessView;
}
public int Width { get; set; }
public int Height { get; set; }
public ShaderResourceView? ShaderResourceView { get; set; }
public UnorderedAccessView? UnorderedAccessView { get; set; }
}
}