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
18 if (expression.TypeExpression == null)
19 {
20 context.Emit(BadOpCode.DefVar, expression.Position, expression.Name, expression.IsReadOnly);
21 }
22 else
23 {
24 context.Compile(expression.TypeExpression);
25 context.Emit(BadOpCode.DefVarTyped, expression.Position, expression.Name, expression.IsReadOnly);
26 }
27 }
28}
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