Beispiel #1
0
 /// <summary>
 /// Creates a new binary expression.
 ///
 /// <param name="op">binary operator</param>
 /// <param name="_left">left operand</param>
 /// <param name="_right">right operand</param>
 /// <param name="source">reference to source code</param>
 /// <returns>newly created binary expression</returns>
 /// </summary>
 public BinaryExpression(BinaryOperator op, Expression _left, Expression _right, SourceReference source = null)
 {
     Operator         = op;
     left             = _left;
     right            = _right;
     source_reference = source;
 }
 public GlobalInitializer(SourceReference<string> globalName, ISourceCodeReferenceService sourceCodeService, ISourceCodeReferenceService methodSourceCodeService, IntermediateInitializerCode code)
     : base(sourceCodeService, methodSourceCodeService, code)
 {
     if (globalName == null)
         throw new ArgumentNullException("globalName");
     this.GlobalName = globalName;
 }
 private void ValidateStorageSourceReference(SourceReference storageSourceReference, int sourceTypeId)
 {
     if (storageSourceReference == null)
     {
         throw new NotFoundSourceReferenceException(sourceTypeId);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Creates a new lambda expression with statement body.
        ///
        /// <param name="statement_body">statement body</param>
        /// <param name="source_reference">reference to source code</param>
        /// <returns>newly created lambda expression</returns>
        /// </summary>
        public static LambdaExpression with_statement_body(Block statement_body, SourceReference source_reference)
        {
            LambdaExpression @this = new LambdaExpression(null, source_reference);

            @this.statement_body = statement_body;
            return(@this);
        }
Beispiel #5
0
        public static MemberAccess pointer(Expression inner, string member_name, SourceReference source_reference = null)
        {
            MemberAccess @this = new MemberAccess(inner, member_name, source_reference);

            @this.pointer_member_access = true;
            return(@this);
        }
Beispiel #6
0
 /// <summary>
 /// Creates a new if statement.
 ///
 /// <param name="cond">a boolean condition</param>
 /// <param name="true_stmt">statement to be evaluated if condition is true</param>
 /// <param name="false_stmt">statement to be evaluated if condition is false</param>
 /// <returns>newly created if statement</returns>
 /// </summary>
 public IfStatement(Expression cond, Block true_stmt, Block false_stmt, SourceReference source)
 {
     condition        = cond;
     true_statement   = true_stmt;
     false_statement  = false_stmt;
     source_reference = source;
 }
Beispiel #7
0
 /// <summary>
 /// Creates a new definition description of a Smalltalk class.
 /// </summary>
 /// <param name="className">Name of the class.</param>
 /// <param name="superclassName">Name of the superclass.</param>
 /// <param name="instanceState">Instance state of class, i.e. Byte-Indexable, Object-Indexable or Named-Instance-Variables.</param>
 /// <param name="classInstanceVariableNames">Names of the class-instance-variables directly defined in this class.</param>
 /// <param name="classVariableNames">Names of the class-variables directly defined in this class.</param>
 /// <param name="instanceVariableNames">Names of the instance-variables directly defined in this class.</param>
 /// <param name="importedPoolNames">Names of the pools imported by this class.</param>
 public ClassDefinition(SourceReference<string> className, SourceReference<string> superclassName,
     SourceReference<SmalltalkClass.InstanceStateEnum> instanceState, IEnumerable<SourceReference<string>> classInstanceVariableNames,
     IEnumerable<SourceReference<string>> classVariableNames, IEnumerable<SourceReference<string>> instanceVariableNames,
     IEnumerable<SourceReference<string>> importedPoolNames)
     : base(className)
 {
     if (superclassName == null)
         throw new ArgumentNullException("superclassName");
     if (instanceState == null)
         throw new ArgumentNullException("instanceState");
     if (classInstanceVariableNames == null)
         throw new ArgumentNullException("classInstanceVariableNames");
     if (classVariableNames == null)
         throw new ArgumentNullException("classVariableNames");
     if (instanceVariableNames == null)
         throw new ArgumentNullException("instanceVariableNames");
     if (importedPoolNames == null)
         throw new ArgumentNullException("importedPoolNames");
     this.SuperclassName = superclassName;
     this.InstanceState = instanceState;
     this.ClassInstanceVariableNames = classInstanceVariableNames;
     this.ClassVariableNames = classVariableNames;
     this.InstanceVariableNames = instanceVariableNames;
     this.ImportedPoolNames = importedPoolNames;
 }
 public override void ReportOtherError(SourceReference reference, string message)
 {
     MakeDirty();
     buffer.Write("<tr><td>");
     reference.Write(buffer, "  ", seen);
     buffer.Write("</td><td>{0}</td></tr>", message);
 }
Beispiel #9
0
 /// <summary>
 /// Creates a new conditional expression.
 ///
 /// <param name="cond">a condition</param>
 /// <param name="true_expr">expression to be evaluated if condition is true</param>
 /// <param name="false_expr">expression to be evaluated if condition is false</param>
 /// <returns>newly created conditional expression</returns>
 /// </summary>
 public ConditionalExpression(Expression cond, Expression true_expr, Expression false_expr, SourceReference source)
 {
     condition        = cond;
     true_expression  = true_expr;
     false_expression = false_expr;
     source_reference = source;
 }
Beispiel #10
0
 public ErrorType(ErrorDomain error_domain, ErrorCode error_code, SourceReference source_reference = null)
 {
     this.error_domain     = error_domain;
     this.data_type        = error_domain;
     this.error_code       = error_code;
     this.source_reference = source_reference;
 }
Beispiel #11
0
 /// <summary>
 /// Creates a new cast expression.
 ///
 /// <param name="inner">expression to be cast</param>
 /// <param name="type_reference">target type</param>
 /// <returns>newly created cast expression</returns>
 /// </summary>
 public CastExpression(Expression inner, DataType type_reference, SourceReference source_reference, bool is_silent_cast)
 {
     this.type_reference   = type_reference;
     this.source_reference = source_reference;
     this.is_silent_cast   = is_silent_cast;
     this.inner            = inner;
 }
Beispiel #12
0
        public static void error(SourceReference source, string message)
        {
            var report = CodeContext.get().report;

            report.err(source, message);
            report.OnReport?.Invoke(report, new ReportEventArgs(ReportType.Error, message, source));
        }
Beispiel #13
0
    public IEnumerator ErrorResponseTest()
    {
        // Tell the server its id (so he doesn't try to pass the message on)
        ConfigController.ApplicationSettings.id = new SourceReference(1, 1, 1, 0);
        ServerCore.Init();
        string returnValue = null;

        ClientSocket.Instance.OnError +=
            (CoflnetException coflnetException) => {
            returnValue = coflnetException.Slug;
        };

        ClientSocket.Instance.Reconnect();
        yield return(new UnityEngine.WaitForSeconds(1));

        var newId = new SourceReference(1, 1, 1, ThreadSaveIdGenerator.NextId);

        // the error is whitelisted
        // beause the console is also the server console this would cause the test to faild otherwise
        LogAssert.Expect(UnityEngine.LogType.Error,
                         new Regex($".*{Regex.Escape(newId.ToString())}.*wasn't found on this server.*"));

        ClientSocket.Instance.SendCommand(new CommandData(newId), false);

        yield return(new UnityEngine.WaitForSeconds(1));

        // test the expected error slug
        Assert.AreEqual(returnValue, "object_not_found");

        ServerCore.Stop();
        //retrivedRes.GetCommandController().ExecuteCommand(new CommandData(id, null, "coreTest"));
    }
Beispiel #14
0
        public static void experimental(SourceReference source, string message)
        {
            var report = CodeContext.get().report;

            report.depr(source, message);
            report.OnReport?.Invoke(report, new ReportEventArgs(ReportType.Experimental, message, source));
        }
Beispiel #15
0
        public static void warning(SourceReference source, string message)
        {
            var report = CodeContext.get().report;

            report.warn(source, message);
            report.OnReport?.Invoke(report, new ReportEventArgs(ReportType.Warning, message, source));
        }
Beispiel #16
0
 public BaseTime(TaskMaster task_master, SourceReference source_ref,
                 Context context, Frame self, Frame container) : base(task_master)
 {
     this.source_reference = source_ref;
     this.context          = context;
     this.container        = self;
 }
Beispiel #17
0
        /// <summary>
        /// Adds a media reference to the current relationship.
        /// </summary>
        /// <param name="description">The <see cref="SourceDescriptionState"/> that represents the media reference to add.</param>
        /// <param name="options">The options to apply before executing the REST API call.</param>
        /// <returns>
        /// A <see cref="RelationshipState"/> instance containing the REST API response.
        /// </returns>
        public RelationshipState AddMediaReference(SourceDescriptionState description, params IStateTransitionOption[] options)
        {
            SourceReference reference = new SourceReference();

            reference.DescriptionRef = description.GetSelfUri();
            return(AddMediaReference(reference, options));
        }
Beispiel #18
0
        public void MoveEnity(SourceReference Id, Direction direction)
        {
            var entity = GetEntity(Id);

            entity.Direction = direction;

            var newPosition = DetermineNewPosition(entity.Position, direction);

            if (!Map.IsFree(newPosition))
            {
                entity.HitWall(direction);
                return;
            }


            // is there another entity?
            if (Entities.Values.Where(e => e.Position == newPosition).Any())
            {
                // we have a collision ladies and gentleman
                var opponent = Entities.Values.Where(e => e.Position == newPosition).First();

                // both die now
                opponent.Collision(entity);
                entity.Collision(opponent);
            }

            entity.Position = newPosition;
            SendCommand(ProxyMessageData.Create("moveTo", new MoveToParams(entity.Id, newPosition, entity.Direction)));
        }
Beispiel #19
0
        public bool Compile(CompilationPass pass, ICompiler compiler, CompileToolContext context)
        {
            var sourceRefs = new SourceReference[] { this._sourceRef };
            var project = (IProjectScope)Parent;

            switch (pass)
            {
                case CompilationPass.Pass1RegisterIdentifiers:
                    IIdentifierScope scope;
                    var existingDef = project.Find(this._labelIdentifier, out scope);
                    if (existingDef != null && scope == project)
                    {
                        context.AddMessage(new BinaryCompileMessage { Filename = this._filename, Line = 0, Message = "Identifier already exists in this scope", MessageLevel = Level.Error });
                        return false;
                    }
                    this._labelInstruction = new LabelInstruction(sourceRefs);
                    project.Add(new BinaryFileLabel(this._labelIdentifier, this._labelInstruction, this._sourceRef));
                    break;

                case CompilationPass.Pass3GenerateCode:
                    compiler.AddInstruction(this._labelInstruction, context);
                    compiler.AddInstruction(new BinaryFileDataInstruction(this._filename, sourceRefs), context);
                    break;
            }

            return true;
        }
Beispiel #20
0
 public Symbol(string name, SourceReference source_reference, Comment comment = null)
 {
     this.name             = name;
     this.source_reference = source_reference;
     this.comment          = comment;
     _scope = new Scope(this);
 }
Beispiel #21
0
 /// <summary>
 /// Creates a new catch
 ///
 /// <param name="error_type">error type</param>
 /// <param name="variable_name">error variable name</param>
 /// <param name="body">error handler body</param>
 /// <param name="source_reference">reference to source code</param>
 /// <returns>newly created catch clause</returns>
 /// </summary>
 public CatchClause(DataType error_type, string variable_name, Block body, SourceReference source_reference = null)
 {
     this.error_type       = error_type;
     this.variable_name    = variable_name;
     this.body             = body;
     this.source_reference = source_reference;
 }
 private Range RangeFromSourceReference(SourceReference source)
 {
     return(new Range {
         start = PositionFromSourceLocation(source?.begin),
         end = PositionFromSourceLocation(source?.end)
     });
 }
Beispiel #23
0
        /// <summary>
        /// Creates a new enum value with the specified numerical representation.
        ///
        /// <param name="name">enum value name</param>
        /// <param name="value">numerical representation</param>
        /// <returns>newly created enum value</returns>
        /// </summary>
        public static ErrorCode with_value(string name, Expression value, SourceReference source_reference = null)
        {
            ErrorCode err = new ErrorCode(name, source_reference);

            err.value = value;
            return(err);
        }
Beispiel #24
0
        /// <summary>
        /// Creates a new type reference.
        ///
        /// <param name="symbol">unresolved type symbol</param>
        /// <param name="source">reference to source code</param>
        /// <returns>newly created type reference</returns>
        /// </summary>
        public static UnresolvedType from_symbol(UnresolvedSymbol symbol, SourceReference source = null)
        {
            UnresolvedType @this = new UnresolvedType();

            @this.unresolved_symbol = symbol;
            @this.source_reference  = source;
            return(@this);
        }
Beispiel #25
0
 /// <summary>
 /// Create a new definition (description) of a global object.
 /// </summary>
 /// <param name="name">Name of the global.</param>
 protected GlobalBase(SourceReference <string> name)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     this.Name = name;
 }
        public async Task <SourceReference> InsertSourceReferenceAsync(SourceReference sourceReference)
        {
            var sourceReferenceEntry = await SourceReferences.AddAsync(sourceReference);

            await SaveChangesAsync();

            return(sourceReferenceEntry.Entity);
        }
        public async Task <SourceReference> DeleteSourceReferenceAsync(SourceReference sourceReference)
        {
            var sourceReferenceEntry = SourceReferences.Remove(sourceReference);

            await SaveChangesAsync();

            return(sourceReferenceEntry.Entity);
        }
Beispiel #28
0
        public BinaryFileScope(INode parent, string labelIdentifier, string filename)
        {
            this.Parent = parent;
            this._labelIdentifier = labelIdentifier;
            this._filename = filename;

            this._sourceRef = new SourceReference(filename, 0, 0, 0, 0, 0);
        }
Beispiel #29
0
 public void WriteDataTo(BinaryWriter writer)
 {
     writer.WriteGuid(Id);
     Object.Write(writer);
     writer.Write(Property);
     Optional.Write(writer, Value, writer.Write);
     SourceReference.Write(writer, Source);
 }
Beispiel #30
0
        /// <summary>
        /// Creates a new ellipsis parameter representing an indefinite number of
        /// parameters.
        /// </summary>
        public static Parameter with_ellipsis(SourceReference source_reference = null)
        {
            Parameter param = new Parameter(null, null, source_reference);

            param.ellipsis = true;
            param.access   = SymbolAccessibility.PUBLIC;
            return(param);
        }
 /// <summary>
 /// Creates a definition description of a pool variable or pool constant.
 /// </summary>
 /// <param name="poolName">Name of the Pool that owns the pool variable or pool constant.</param>
 /// <param name="variableName">Name of the pool variable or pool constant.</param>
 public PoolValueDefinition(SourceReference<string> poolName, SourceReference<string> variableName)
 {
     if (poolName == null)
         throw new ArgumentNullException("poolName");
     if (variableName == null)
         throw new ArgumentNullException("variableName");
     this.PoolName = poolName;
     this.VariableName = variableName;
 }
Beispiel #32
0
        public static bool BetweenPosition(this SourceReference @this, Position pos)
        {
            var adjCol = pos.character + 1;
            var adjRow = pos.line + 1;

            return
                ((adjRow >= @this.begin.line && adjRow <= @this.end.line) &&
                 (adjCol >= @this.begin.column && adjCol <= @this.end.column));
        }
Beispiel #33
0
        public static CastExpression non_null(Expression inner, SourceReference source_reference)
        {
            CastExpression @this = new CastExpression();

            @this.inner            = inner;
            @this.is_non_null_cast = true;
            @this.source_reference = source_reference;
            return(@this);
        }
Beispiel #34
0
 /// <summary>
 /// Creates a new property.
 ///
 /// <param name="name">property name</param>
 /// <param name="property_type">property type</param>
 /// <param name="get_accessor">get accessor</param>
 /// <param name="set_accessor">set/construct accessor</param>
 /// <param name="source_reference">reference to source code</param>
 /// <returns>newly created property</returns>
 /// </summary>
 public Property(
     string name, DataType property_type, PropertyAccessor get_accessor,
     PropertyAccessor set_accessor, SourceReference source_reference = null, Comment comment = null
     ) : base(name, source_reference, comment)
 {
     this.property_type = property_type;
     this.get_accessor  = get_accessor;
     this.set_accessor  = set_accessor;
 }
Beispiel #35
0
        /// <summary>
        /// Reports the specified message as note.
        ///
        /// <param name="source">reference to source code</param>
        /// <param name="message">note message</param>
        /// </summary>
        public virtual void note(SourceReference source, string message)
        {
            if (!enable_warnings)
            {
                return;
            }

            print_message(source, "note", note_color_start, note_color_end, message, verbose_errors);
        }
 public PoolVariableInitializer(SourceReference<string> poolName, SourceReference<string> variableName, ISourceCodeReferenceService sourceCodeService, ISourceCodeReferenceService methodSourceCodeService, IntermediateInitializerCode code)
     : base(sourceCodeService, methodSourceCodeService, code)
 {
     if (poolName == null)
         throw new ArgumentNullException("poolName");
     if (variableName == null)
         throw new ArgumentNullException("variableName");
     this.PoolName = poolName;
     this.VariableName = variableName;
 }
Beispiel #37
0
 /// <summary>
 /// Create a new definition (description) of a global object.
 /// </summary>
 /// <param name="name">Name of the global.</param>
 protected GlobalBase(SourceReference<string> name)
 {
     if (name == null)
         throw new ArgumentNullException("name");
     this.Name = name;
 }
 /// <summary>
 /// Creates a definition description of a pool constant.
 /// </summary>
 /// <param name="poolName">Name of the Pool that owns the pool constant.</param>
 /// <param name="variableName">Name of the pool constant.</param>
 public PoolConstantDefinition(SourceReference<string> poolName, SourceReference<string> variableName)
     : base(poolName, variableName)
 {
 }
 /// <summary>
 /// Creates a new definition description of a global constant.
 /// </summary>
 /// <param name="globalName">Name of the global.</param>
 public GlobalConstantDefinition(SourceReference<string> globalName)
     : base(globalName)
 {
 }
Beispiel #40
0
 /// <summary>
 /// Creates a new definition description of a Shared Pool.
 /// </summary>
 /// <param name="poolName">Name of the Pool.</param>
 public PoolDefinition(SourceReference<string> poolName)
     : base(poolName)
 {
 }
 public ClassMethodDefinition(SourceReference<string> className, SourceReference<string> selector, ISourceCodeReferenceService sourceCodeService, ISourceCodeReferenceService methodSourceCodeService, IntermediateMethodCode code)
     : base(className, selector, sourceCodeService, methodSourceCodeService, code)
 {
 }
Beispiel #42
0
 public BinaryFileLabel(string name, LabelInstruction label, SourceReference sourceRef)
 {
     this._name = name;
     this._label = label;
     this._sourceRef = sourceRef;
 }
 /// <summary>
 /// Creates a new definition description of a global variable.
 /// </summary>
 /// <param name="globalName">Name of the global.</param>
 public GlobalVariableDefinition(SourceReference<string> globalName)
     : base(globalName)
 {
 }