public override object VisitFieldOrClassAssignment([NotNull] ClepsParser.FieldOrClassAssignmentContext context) { List <string> namespaceClassAndFieldHierarchy = context._ClassHierarchy.Select(h => h.GetText()).ToList(); bool classFound = false; int i; for (i = namespaceClassAndFieldHierarchy.Count; i >= 1; i--) { string classNameToTest = String.Join(".", namespaceClassAndFieldHierarchy.Take(i).ToList()); if (ClassManager.IsClassBodySet(classNameToTest)) { classFound = true; break; } } if (!classFound) { string errorMessage = String.Format("Could not find class or field {0}", String.Join(".", namespaceClassAndFieldHierarchy)); Status.AddError(new CompilerError(FileName, context.Start.Line, context.Start.Column, errorMessage)); //just return something to avoid stalling return(CodeGenerator.CreateByte(0)); } string fullClassName = String.Join(".", namespaceClassAndFieldHierarchy.Take(i).ToList()); ClepsClass currentClass = ClassManager.GetClass(fullClassName); BasicStaticClepsType currentType = new BasicStaticClepsType(fullClassName); var fieldAccesses = namespaceClassAndFieldHierarchy.Skip(i).ToList(); if (fieldAccesses.Count != 0) { throw new NotImplementedException("Getting fields on static classes is not supported yet"); } IValue ret = CodeGenerator.GetClassStaticInstance(currentType); return(ret); }
public IValue GetClassStaticInstance(BasicStaticClepsType clepsClass) { throw new NotImplementedException(); }
public IValue GetClassStaticInstance(BasicStaticClepsType clepsClass) { JavaScriptValue ret = new JavaScriptValue(TOPLEVELNAMESPACE + "." + clepsClass.RawTypeName + "Inst", clepsClass); return(ret); }