Example #1
0
        public override void ResolveTypes(CompileContext context, Model.Scope enclosingScope)
        {
            _struct = enclosingScope.FindType(typeName);
            if (_struct == null)
            {
                CachedFetchToken = Constant(0);
                context.ReportError(this, "Could not find type " + typeName);
            }
            else if (_struct.size == 0)
            {
                throw new InternalError("Struct size must be determined before types are resolved.");
            }
            else
                CachedFetchToken = Constant((ushort)_struct.size);

             ResultType = "word";
        }
Example #2
0
        public override void ResolveTypes(CompileContext context, Model.Scope enclosingScope)
        {
            _struct = enclosingScope.FindType(typeName);

            if (_struct == null)
            {
                context.ReportError(this, "Could not find type " + typeName);
                CachedFetchToken = Constant(0);
            }
            else
            {
                var memberIndex = _struct.members.FindIndex(m => m.name == memberName);
                if (memberIndex < 0)
                {
                    context.ReportError(this, "Member not found : " + memberName);
                    CachedFetchToken = Constant(0);
                }
                else
                    CachedFetchToken = Constant((ushort)memberIndex);
            }

            ResultType = "word";
        }
Example #3
0
 public override void ResolveTypes(CompileContext context, Model.Scope enclosingScope)
 {
     Child(0).ResolveTypes(context, enclosingScope);
     _struct = enclosingScope.FindType(Child(0).ResultType);
     if (_struct == null)
     {
         context.ReportError(this, "Result of expression is not a struct");
         ResultType = "word";
     }
     else
     {
         foreach (var _member in _struct.members)
             if (_member.name == memberName) member = _member;
         if (member == null)
         {
             context.ReportError(this, "Member " + memberName + " not found on " + _struct.name);
             ResultType = "word";
         }
         else
             ResultType = member.typeSpecifier;
     }
 }