Exemplo n.º 1
0
        public void ProcessStatementForList(DMASTProcStatementForList statementForList)
        {
            DMExpression.Emit(_dmObject, _proc, statementForList.List);
            _proc.CreateListEnumerator();
            _proc.StartScope();
            {
                if (statementForList.Initializer != null)
                {
                    ProcessStatement(statementForList.Initializer);
                }

                string loopLabel = _proc.NewLabelName();
                _proc.LoopStart(loopLabel);
                {
                    DMExpression outputVariable = DMExpression.Create(_dmObject, _proc, statementForList.Variable);
                    (DMReference outputRef, _) = outputVariable.EmitReference(_dmObject, _proc);
                    _proc.Enumerate(outputRef);
                    _proc.BreakIfFalse();

                    DMASTProcStatementVarDeclaration varDeclaration = statementForList.Initializer as DMASTProcStatementVarDeclaration;
                    if (varDeclaration != null && varDeclaration.Type != null)
                    {
                        //This is terrible but temporary
                        //TODO: See https://github.com/wixoaGit/OpenDream/issues/50
                        var obj = DMObjectTree.GetDMObject(varDeclaration.Type.Value);
                        if (statementForList.List is DMASTIdentifier list && list.Identifier == "world" && !obj.IsSubtypeOf(DreamPath.Atom))
                        {
                            var warn = new CompilerWarning(statementForList.Location, "Cannot currently loop 'in world' for non-ATOM types");
                            DMCompiler.Warning(warn);
                        }
                        DMExpression.Emit(_dmObject, _proc, statementForList.Variable);
                        _proc.PushPath(varDeclaration.Type.Value);
                        _proc.IsType();

                        _proc.ContinueIfFalse();
                    }

                    ProcessBlockInner(statementForList.Body);

                    _proc.LoopContinue(loopLabel);
                    _proc.LoopJumpToStart(loopLabel);
                }
                _proc.LoopEnd();
            }
            _proc.EndScope();
            _proc.DestroyEnumerator();
        }
Exemplo n.º 2
0
        private void AddWarning(CompilerWarning warning, Location loc, params object[] args)
        {
            if (options.NoWarnings)
            {
                return;
            }

            if ((options.IgnoreWarnings.Contains((int)warning) || disabledWarnings.Contains((int)warning)) &&
                !enabledWarnings.Contains((int)warning))
            {
                return;
            }

            var str = string.Format(CompilerErrors.ResourceManager.GetString(warning.ToString()) ?? warning.ToString(), args);

            AddMessage(new BuildMessage(str, BuildMessageType.Warning, (int)warning, Line(loc), Col(loc), unit.FileName));
        }
 //returns true if a stub has been created, false otherwise.
 //TODO: add entity argument to the method to not need return type?
 bool AbstractMemberNotImplemented(ClassDefinition node, TypeReference baseTypeRef, IMember member)
 {
     if (IsValueType(node))
     {
         Error(CompilerErrorFactory.ValueTypeCantHaveAbstractMember(baseTypeRef, node.FullName, GetAbstractMemberSignature(member)));
         return(false);
     }
     if (!node.IsAbstract)
     {
         //BEHAVIOR >= 0.7.7:	(see BOO-789 for details)
         //create a stub for this not implemented member
         //it will raise a NotImplementedException if called at runtime
         TypeMember      m       = CodeBuilder.CreateStub(member);
         CompilerWarning warning = null;
         if (null != m)
         {
             //FIXME: cannot reorder upstream? => base before derived
             foreach (TypeMember existing in node.Members)
             {
                 if (existing.Name == m.Name)
                 {
                     return(true);
                 }
             }
             warning = CompilerWarningFactory.AbstractMemberNotImplementedStubCreated(baseTypeRef,
                                                                                      node.FullName, GetAbstractMemberSignature(member));
             node.Members.Add(m);
         }
         else
         {
             warning = CompilerWarningFactory.AbstractMemberNotImplemented(baseTypeRef,
                                                                           node.FullName, GetAbstractMemberSignature(member));
             _newAbstractClasses.AddUnique(node);
         }
         Warnings.Add(warning);
         return(null != m);
     }
     return(false);
 }
Exemplo n.º 4
0
 public static void Warning(CompilerWarning warning)
 {
     Console.WriteLine(warning);
     WarningCount++;
 }
Exemplo n.º 5
0
 private void EmitWarning(CompilerWarning warning)
 {
     My <CompilerWarningCollection> .Instance.Add(warning);
 }
Exemplo n.º 6
0
 public void MapParsingMessage(CompilerWarning warning)
 {
     MapParsingMessage(warning.LexicalInfo);
 }
Exemplo n.º 7
0
        private bool CompilerWarningAsWarning(CompilerWarning compilerWarning)
        {
            Warn(compilerWarning.Token, compilerWarning.Message);

            return(false);
        }
Exemplo n.º 8
0
        private bool CompilerWarningAsError(CompilerWarning compilerWarning)
        {
            Error(compilerWarning.Token, compilerWarning.Message);

            return(true);
        }
Exemplo n.º 9
0
 private static bool AssertFailCompilerWarningHandler(CompilerWarning compilerWarning)
 {
     throw new Exception($"CompilerWarning occurred: {compilerWarning.Message}", compilerWarning);
 }
Exemplo n.º 10
0
 public void MapMessage(CompilerWarning warning)
 {
     messages.Add(new CompilerMessage(warning.LexicalInfo, warning.Code, warning.Message, TaskErrorCategory.Warning));
 }
Exemplo n.º 11
0
 private static bool FatalWarningsHandler(CompilerWarning compilerWarning)
 {
     throw compilerWarning;
 }