Esempio n. 1
0
 public TermExpression(
     Token start,
     Expression left,
     Keyword oper,
     Expression right)
     : base(start)
 {
     this.Left = left;
     this.Operator = oper;
     this.Right = right;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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;
 }
Esempio n. 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;
        }
Esempio n. 6
0
 public NewExpression(Token start, TypeReference typeReference, IEnumerable<Expression> constructorArguments)
     : base(start)
 {
     this.typeReference = typeReference;
     this.constructorArguments.AddRange(constructorArguments);
 }
Esempio n. 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;
        }
Esempio n. 8
0
 protected ParseNode(Token start)
 {
     this.start = start;
 }
Esempio n. 9
0
 public BlockStatement(Token start)
     : base(start)
 {
 }
Esempio n. 10
0
 public PointerTypeReference(Token start, TypeReference elementType)
     : base(start)
 {
     this.ElementType = elementType;
 }
Esempio n. 11
0
 public ParameterDeclaration(Token start, IEnumerable<string> parameterNames, TypeReference type)
     : base(start)
 {
     this.type = type;
     this.parameterNames.AddRange(parameterNames);
 }
Esempio n. 12
0
 public WhileStatement(Token start)
     : base(start)
 {
 }
Esempio n. 13
0
 public ArrayTypeReference(Token start, Expression elementCount, TypeReference elementType)
     : base(start)
 {
     this.ElementCount = elementCount;
     this.ElementType = elementType;
 }
Esempio n. 14
0
 protected ReferenceExpression(Token start)
     : base(start)
 {
 }
Esempio n. 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;
        }
Esempio n. 16
0
 public NamedReferenceExpression(Token start, string identifier)
     : base(start)
 {
     this.Identifier = identifier;
 }
Esempio n. 17
0
 public MemberReferenceExpression(Token start, ReferenceExpression inner, string memberName)
     : base(start)
 {
     this.MemberName = memberName;
     this.Inner = inner;
 }
Esempio n. 18
0
 public ArrayIndexReferenceExpression(Token start, ReferenceExpression inner, Expression index)
     : base(start)
 {
     this.Inner = inner;
     this.Index = index;
 }
Esempio n. 19
0
 public InheritedReferenceExpression(Token start)
     : base(start)
 {
 }
Esempio n. 20
0
 public AssignmentStatement(Token start, ReferenceExpression storage, Expression value)
     : base(start)
 {
     this.Value = value;
     this.Storage = storage;
 }
Esempio n. 21
0
 public AddressExpression(Token start, ReferenceExpression inner)
     : base(start)
 {
     this.Inner = inner;
 }
Esempio n. 22
0
 public IfStatement(Token start)
     : base(start)
 {
 }
Esempio n. 23
0
 protected Expression(Token start)
     : base(start)
 {
 }
Esempio n. 24
0
 protected TypeDeclaration(Token start, string name)
     : base(start)
 {
     this.Name = name;
 }
Esempio n. 25
0
 public NamedTypeReference(Token start, string typeName)
     : base(start)
 {
     this.TypeName = typeName;
 }
Esempio n. 26
0
 public CallStatement(Token start, ReferenceExpression callExpression)
     : base(start)
 {
     this.Expression = callExpression;
 }
Esempio n. 27
0
 protected TypeReference(Token start)
     : base(start)
 {
 }
Esempio n. 28
0
 public NotExpression(Token start, Expression inner)
     : base(start)
 {
     this.Inner = inner;
 }
Esempio n. 29
0
 public LiteralExpression(Token start, object value)
     : base(start)
 {
     this.Value = value;
 }
Esempio n. 30
0
 public ProgramUnit(Token start)
     : base(start)
 {
 }