BadScript 2
Loading...
Searching...
No Matches
BadVariableDefinitionExpressionCompiler.cs
Go to the documentation of this file.
2
4
8public class BadVariableDefinitionExpressionCompiler : BadExpressionCompiler<BadVariableDefinitionExpression>
9{
12 {
13 if (expression.Attributes.Any())
14 {
15 throw new BadCompilerException("Attributes are not supported yet.");
16 }
17 if (expression.TypeExpression == null)
18 {
19 context.Emit(BadOpCode.DefVar, expression.Position, expression.Name, expression.IsReadOnly);
20 }
21 else
22 {
23 context.Compile(expression.TypeExpression);
24 context.Emit(BadOpCode.DefVarTyped, expression.Position, expression.Name, expression.IsReadOnly);
25 }
26 }
27}
IEnumerable< BadExpression > Attributes
BadSourcePosition Position
The source Position of the Expression.
bool IsReadOnly
Indicates if the Variable will be declared as Read-Only.
Gets thrown when a Compiler is not able to compile a specific BadExpression.
override void Compile(BadExpressionCompileContext context, BadVariableDefinitionExpression expression)
Contains the Variable Expressions for the BadScript2 Language.
BadOpCode
Defines the Operations that the BadVirtualMachine can execute.
Definition BadOpCode.cs:7