Beispiel #1
0
 public TermExpression(
     Token start,
     Expression left,
     Keyword oper,
     Expression right)
     : base(start)
 {
     this.Left = left;
     this.Operator = oper;
     this.Right = right;
 }
Beispiel #2
0
 public VariableDeclaration(
     Token start, 
     IEnumerable<string> variableNames, 
     TypeReference type,
     Expression initExpression)
     : base(start)
 {
     this.type = type;
     this.variableNames.AddRange(variableNames);
     this.InitExpression = initExpression;
 }
Beispiel #3
0
 public ClassDeclaration(
     Token start, 
     string name, 
     string baseType,
     bool isStatic, 
     bool isPublic)
     : base(start, name)
 {
     this.IsPublic = isPublic;
     this.IsStatic = isStatic;
     this.BaseType = baseType;
 }
Beispiel #4
0
 public MethodDeclaration(
     Token start, 
     string name, 
     bool isStatic, 
     bool isVirtual,
     bool isAbstract)
     : base(start)
 {
     this.MethodName = name;
     this.IsStatic = isStatic;
     this.IsVirtual = isVirtual;
     this.IsAbstract = isAbstract;
 }
Beispiel #5
0
        private bool TryEmitAllocCall(Token start, CompilerContext context, Scope scope, MethodImpl method, int size)
        {
            TypeDefinition memoryType = null;
            if (!this.TryFindSystemMemory(start, context, out memoryType))
            {
                return false;
            }

            MethodInfo allocMethod = memoryType.Methods.FirstOrDefault(e => string.CompareOrdinal("Alloc", e.Name) == 0);
            if (allocMethod == null)
            {
                log.Write(new Message(
                    start.Path,
                    start.Line,
                    start.Column,
                    Severity.Error,
                    Properties.Resources.CodeGenerator_SystemMemoryMissingAlloc));
                return false;
            }

            method.Module.AddProto(allocMethod);
            method.Statements.Add(new AsmStatement { Instruction = "mov eax," + size.ToString() });
            method.Statements.Add(new AsmStatement { Instruction = "push eax" });
            method.Statements.Add(new AsmStatement { Instruction = "call " + allocMethod.MangledName });
            method.Statements.Add(new AsmStatement { Instruction = "add esp,4" });
            return true;
        }
Beispiel #6
0
 public NewExpression(Token start, TypeReference typeReference, IEnumerable<Expression> constructorArguments)
     : base(start)
 {
     this.typeReference = typeReference;
     this.constructorArguments.AddRange(constructorArguments);
 }
Beispiel #7
0
        private bool TryFindSystemMemory(Token start, CompilerContext context, out TypeDefinition memoryType)
        {
            if (!context.TryFindTypeByName("System.Memory", out memoryType))
            {
                log.Write(new Message(
                    start.Path,
                    start.Line,
                    start.Column,
                    Severity.Error,
                    Properties.Resources.CodeGenerator_SystemMemoryNotDeclared));
                return false;
            }

            return true;
        }
Beispiel #8
0
 protected ParseNode(Token start)
 {
     this.start = start;
 }
Beispiel #9
0
 public BlockStatement(Token start)
     : base(start)
 {
 }
Beispiel #10
0
 public PointerTypeReference(Token start, TypeReference elementType)
     : base(start)
 {
     this.ElementType = elementType;
 }
Beispiel #11
0
 public ParameterDeclaration(Token start, IEnumerable<string> parameterNames, TypeReference type)
     : base(start)
 {
     this.type = type;
     this.parameterNames.AddRange(parameterNames);
 }
Beispiel #12
0
 public WhileStatement(Token start)
     : base(start)
 {
 }
Beispiel #13
0
 public ArrayTypeReference(Token start, Expression elementCount, TypeReference elementType)
     : base(start)
 {
     this.ElementCount = elementCount;
     this.ElementType = elementType;
 }
Beispiel #14
0
 protected ReferenceExpression(Token start)
     : base(start)
 {
 }
Beispiel #15
0
        private bool TryEmitFreeCall(Token start, CompilerContext context, Scope scope, MethodImpl method)
        {
            TypeDefinition memoryType = null;
            if (!this.TryFindSystemMemory(start, context, out memoryType))
            {
                return false;
            }

            MethodInfo freeMethod = memoryType.Methods.FirstOrDefault(e => string.CompareOrdinal(e.Name, "Free") == 0);
            if (freeMethod == null)
            {
                log.Write(new Message(
                    start.Path,
                    start.Line,
                    start.Column,
                    Severity.Error,
                    Properties.Resources.CodeGenerator_SystemMemoryMissingFree));
                return false;
            }

            method.Module.AddProto(freeMethod);
            method.Statements.Add(new AsmStatement { Instruction = string.Format("call {0}", freeMethod.MangledName) });
            return true;
        }
Beispiel #16
0
 public NamedReferenceExpression(Token start, string identifier)
     : base(start)
 {
     this.Identifier = identifier;
 }
Beispiel #17
0
 public MemberReferenceExpression(Token start, ReferenceExpression inner, string memberName)
     : base(start)
 {
     this.MemberName = memberName;
     this.Inner = inner;
 }
Beispiel #18
0
 public ArrayIndexReferenceExpression(Token start, ReferenceExpression inner, Expression index)
     : base(start)
 {
     this.Inner = inner;
     this.Index = index;
 }
Beispiel #19
0
 public InheritedReferenceExpression(Token start)
     : base(start)
 {
 }
Beispiel #20
0
 public AssignmentStatement(Token start, ReferenceExpression storage, Expression value)
     : base(start)
 {
     this.Value = value;
     this.Storage = storage;
 }
Beispiel #21
0
 public AddressExpression(Token start, ReferenceExpression inner)
     : base(start)
 {
     this.Inner = inner;
 }
Beispiel #22
0
 public IfStatement(Token start)
     : base(start)
 {
 }
Beispiel #23
0
 protected Expression(Token start)
     : base(start)
 {
 }
Beispiel #24
0
 protected TypeDeclaration(Token start, string name)
     : base(start)
 {
     this.Name = name;
 }
Beispiel #25
0
 public NamedTypeReference(Token start, string typeName)
     : base(start)
 {
     this.TypeName = typeName;
 }
Beispiel #26
0
 public CallStatement(Token start, ReferenceExpression callExpression)
     : base(start)
 {
     this.Expression = callExpression;
 }
Beispiel #27
0
 protected TypeReference(Token start)
     : base(start)
 {
 }
Beispiel #28
0
 public NotExpression(Token start, Expression inner)
     : base(start)
 {
     this.Inner = inner;
 }
Beispiel #29
0
 public LiteralExpression(Token start, object value)
     : base(start)
 {
     this.Value = value;
 }
Beispiel #30
0
 public ProgramUnit(Token start)
     : base(start)
 {
 }