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