Esempio n. 1
0
        private static void PerformSemanticAnalysis(AbstractSyntaxTree ast)
        {
            foreach (GameObjectNode gameObject in ast.Root.GameObjects.Values)
            {
                new TypeChecker().Visit(gameObject);
            }

            foreach (GameObjectNode gameObject in ast.Root.GameObjects.Values)
            {
                new LinkChecker(ast).Visit(gameObject);
            }

            EnvironmentStore.CleanUp();
        }
Esempio n. 2
0
        public void TypeCheck_Visit_AssignNullFunctionToVariableAllowed()
        {
            AbstractSyntaxTree ast = TestAstBuilder.BuildAst(TestCode7);

            Assert.DoesNotThrow(() => TestDelegate(ast));

            List <string> variablePath = new List <string>()
            {
                "SampleScreen1", "Map", "x"
            };

            ValueNode value = EnvironmentStore.AccessMember(variablePath).ValueNode;

            Assert.That(value == null);
        }
Esempio n. 3
0
        public void TypeCheck_Visit_IntegerPlusFloatSucceeds()
        {
            AbstractSyntaxTree ast = TestAstBuilder.BuildAst(TestCode9);

            Assert.DoesNotThrow(() => TestDelegate(ast));

            List <string> variablePathX = new List <string>()
            {
                "SampleScreen1", "Map", "x"
            };
            List <string> variablePathY = new List <string>()
            {
                "SampleScreen1", "Map", "y"
            };

            ValueNode valueX = EnvironmentStore.AccessMember(variablePathX).ValueNode;
            ValueNode valueY = EnvironmentStore.AccessMember(variablePathY).ValueNode;

            Assert.That(valueX != null, "valueX != null");
            Assert.That(valueX is FloatValueNode {
                Value: 2.5f
            }, "valueX != null");
        public override void Visit(MemberAccessNode memberAccessNode)
        {
            ValueNode member = EnvironmentStore.AccessMember(memberAccessNode).ValueNode;

            switch (member)
            {
            case ArrayNode arrayNode:
                Result = Calculator.GetValue(arrayNode);
                break;

            case IntValueNode intValueNode:
                Result = Calculator.GetValue(intValueNode.Value);
                break;

            case StringNode stringNode:
                Result = Calculator.GetValue(stringNode.Value);
                break;

            case FloatValueNode floatValueNode:
                Result = Calculator.GetValue(floatValueNode.Value);
                break;
            }
        }
Esempio n. 5
0
 private static void CleanUp()
 {
     DazelLogger.HasErrors = false;
     EnvironmentStore.CleanUp();
 }
Esempio n. 6
0
 public void CleanUp()
 {
     EnvironmentStore.CleanUp();
     DazelLogger.HasErrors       = false;
     DazelLogger.ThrowExceptions = false;
 }