Skip to content

Commit

Permalink
Merge branch 'main' into ast
Browse files Browse the repository at this point in the history
  • Loading branch information
samthakur587 authored Jul 31, 2024
2 parents 34edb13 + c5664f7 commit a3aca47
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
35 changes: 21 additions & 14 deletions src/backend/Opengl/OpenglAst.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def __repr__(self):

def __str__(self):
return f"uniform {self.vtype} {self.name};"



class ConstantNode(ASTNode):
def __init__(self, value):
self.value = value
Expand All @@ -23,9 +24,9 @@ def __repr__(self):
def __str__(self):
return str(self.value)


class VersionDirectiveNode(ASTNode):
def __init__(self,number, profile):
def __init__(self, number, profile):
self.version_number = number
self.profile = profile

Expand All @@ -35,13 +36,13 @@ def __repr__(self):
def __str__(self):
return f"#version {self.version_number} {self.profile}"


class LayoutNode:
def __init__(self, location_number, dtype, name):
self.location_number = location_number
self.dtype = dtype
self.name = name


def __repr__(self):
return f"LayoutNode(location={self.location_number}, dtype={self.dtype})"

Expand All @@ -57,9 +58,10 @@ def __init__(self, condition, true_expr, false_expr):

def __repr__(self):
return f"TernaryOpNode(condition={self.condition}, true_expr={self.true_expr}, false_expr={self.false_expr})"



class LayoutNode:
def __init__(self,section, location_number, dtype, name):
def __init__(self, section, location_number, dtype, name):
self.section = section
self.location_number = location_number
self.dtype = dtype
Expand All @@ -69,10 +71,17 @@ def __repr__(self):
return f"LayoutNode(section={self.section}, location_number={self.location_number}, dtype={self.dtype}, name={self.name})"




class ShaderNode:
def __init__(self, version, global_inputs, global_outputs, uniforms, vertex_section, fragment_section, functions):
def __init__(
self,
version,
global_inputs,
global_outputs,
uniforms,
vertex_section,
fragment_section,
functions,
):
self.version = version
self.global_inputs = global_inputs
self.global_outputs = global_outputs
Expand All @@ -86,7 +95,7 @@ def __repr__(self):


class VERTEXShaderNode:
def __init__(self, inputs, outputs,uniform, functions, layout_qualifiers=[]):
def __init__(self, inputs, outputs, uniform, functions, layout_qualifiers=[]):
self.inputs = inputs
self.outputs = outputs
self.uniform = uniform
Expand All @@ -98,17 +107,15 @@ def __repr__(self):


class FRAGMENTShaderNode:
def __init__(self, inputs, outputs,uniform,functions,layout_qualifiers = []):
def __init__(self, inputs, outputs, uniform, functions, layout_qualifiers=[]):
self.inputs = inputs
self.outputs = outputs
self.uniform = uniform
self.functions = functions
self.layout_qualifiers = layout_qualifiers

def __repr__(self):
return (
f"FRAGMENTShaderNode({self.inputs!r}) {self.outputs!r}{self.uniform!r} {self.functions!r}{self.layout_qualifiers!r}"
)
return f"FRAGMENTShaderNode({self.inputs!r}) {self.outputs!r}{self.uniform!r} {self.functions!r}{self.layout_qualifiers!r}"


class FunctionNode(ASTNode):
Expand Down
1 change: 1 addition & 0 deletions src/backend/Opengl/OpenglParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ def parse_shader(self, version_node):
comment_content = (
self.current_token[1].strip().lower()
) # Normalize content

if "vertex shader" in comment_content:
current_section = "VERTEX"
elif "fragment shader" in comment_content:
Expand Down
2 changes: 1 addition & 1 deletion src/backend/Opengl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from .OpenglLexer import Lexer
from .OpenglParser import Parser
from .openglCrossglCodegen import CrossglCodeGen
from .openglCrossglCodegen import CrossglCodeGen
1 change: 1 addition & 0 deletions src/backend/Opengl/openglCrossglCodegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,4 @@ def map_operator(self, op):
"OR": "||",
}
return op_map.get(op, op)

0 comments on commit a3aca47

Please sign in to comment.